Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81938

Blank editor window pops up.

$
0
0

I cant show the site as it has customer info on there.

I use the following code to get data from various tables ( this is invoice data)

Each time it runs I get a editor window popup with no info just a update Invoice button

Any ideas what I am doing wrong to trigger this ?

Cheers

Steve Warby.

getInvoices=function(){

// check if customer already selected. If so dont run the query
        if (currentCustID !== selectedCustID )
        {
        currentCustID = selectedCustID;
  // create editor
        editorInvoices = new $.fn.dataTable.Editor( {
        ajax :  {
                       'url' :  'http://www.xxx.com/php/xxxx.php',
                       "type": "POST",
                       "data": {
                                        'selectedCustID': selectedCustID
                                   }

                  },
        table: "#dtInvoices",
        //template: '#customForm',
        fields: [
            {
                label: "Inv ID:",
                name: "invoice.InvID"
            },
               {
                label: "Del Type:",
                name: "invoice.delMethod",
                type: 'radio',
                options: [
                    'Collected',
                    'Own Van',
                    'Hermes STD',
                    'Hermes Next Day',
                    'Other']},
            {
                label: "Pay Type:",
                name: "invoice.payMethod",
                type: 'radio',
                options: [
                    'Cash',
                    'Cheque',
                    'Account',
                    'PayPal',
                    'Bacs',
                    'Card']
            }, {
                label: "Order Number:",
                name: "invoice.orderNum"
            }, {
                label: "Notes",
                name: "invoice.notes"
            }, {
                label: "Inv Date:",
                name: "invoice.invDate"
            }, {
                label: "Pay Date:",
                name: "invoice.payDate"
            }


                ]


            } );

          editorInvoices.on('initEdit', function (val) {
          editorInvoices.disable(["invoice.InvID"]);
        });

         editorInvoices.on('initCreate', function () {
         //alert('on create ');
          editorInvoices.set( 'CustID', selectedCustID );
          editorInvoices.disable(["invoice.InvID"]);
        });

        editorInvoices.title('Edit entry').buttons('Update Invoice').edit(this);

// set the datatables up..........................................

        $("#dtInvoices").DataTable().destroy();
        $('#dtInvoices').empty();
        tableInvoices = $('#dtInvoices').DataTable( {
        scrollY: "200px",
        scrollCollapse: true,
        paging: false,
        info: false,
        select: true,
        ordering: true,
        order: [[0, 'desc']],
        dom: "Bfrtip",
        autoWidth : true,
        responsive: true,
        bSort:false,
                   // bServerSide: true,
        ajax :       {
                            'url' :  'http://www.xxx.com/php/xxx.php',
                            "type": "POST",
                                  "data": {
                                                'selectedCustID': selectedCustID
                                              }

                          },

        columns: [
            { data: "invoice.InvID" ,  responsivePriority: 2, title : 'Inv No'},
            { data: "invoice.delMethod" , responsivePriority: 2,  title : 'Del Type'},
            { data: "invoice.payMethod" , responsivePriority: 2,  title : 'pay Type'},
            { data: "invoice.invDate" ,  title : ' Inv Date'},
            { data: "invoice.payDate" ,  title : ' Pay Date'},
            { data: "invoice.invNett" ,  title : ' Nett'},
            { data: "invoice.invTax" ,   title : ' Vat'},
            { data: "invoice.invTotal" ,   title : ' Total'},
            { data: "invoice.orderNum" ,   title : ' Order Num'},
            { data: "invoice.notes" ,   title : ' Notes'},
            { data: "invoice.CustID" ,   title : ' Cust No'}

        ],

        buttons: [
            { extend: "create", editor: editorInvoices },
            { extend: "edit",   editor: editorInvoices },
            { text: "Refresh Details",
            action: function (e, dt, node, config) {
                getInvoices();}

            }
        ]
       // console.log('data returned = '+data);
    } );

      $('#dtInvoices').on( 'select.dt', function ( e, dt, type, indexes ) {
      //var data = dt.rows(indexes).data();
      selectedInvoiceID = tableInvoices.cell('.selected', 0).data();
      console.log('selectedInvoiceID = '+ selectedInvoiceID);

        } );

        $('#dtInvoiceDetails_search').on( 'keyup', function () {
        tableInvoiceDetails
        .columns(6)
        .search( this.value )
        .draw();
} );
}
}

php

include( "DataTables.php" );


// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'invoice' , 'InvID')
    ->fields(
        Field::inst( 'invoice.InvID' ),
        Field::inst( 'invoice.CustID' ),
        Field::inst( 'invoice.invDate' ),
        Field::inst( 'invoice.payDate' ),
        Field::inst( 'invoice.delMethod' ),
        Field::inst( 'invoice.payMethod' ),
        Field::inst( 'invoice.invNett' ),
        Field::inst( 'invoice.invTax' ),
        Field::inst( 'invoice.invTotal' ),
        Field::inst( 'invoice.vatRate' ),
        Field::inst( 'invoice.orderNum' ),
        Field::inst( 'invoice.notes' )
            )

    ->process( $_POST )
    ->json();

Viewing all articles
Browse latest Browse all 81938

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>