Insert new record.

Insert new record.

classic12classic12 Posts: 228Questions: 60Answers: 4

Hi guys,

I am using the following logic.

I populate a datatable with all the customer table details and get the customer ID on the click event.

$('#dtCustomers').on( 'select.dt', function ( e, dt, type, indexes ) {
      //var data = dt.rows(indexes).data();
      selectedCustomerID = tableCustomers.cell('.selected', 0).data();
          if (currentCustomerID !== selectedCustomerID )
            {
                getInvoices();
                currentCustomerID = selectedCustomerID;
            }
     } );

I then us the following to get just the invoices for that customer.


ajax : { 'url' : 'http://www.xxxx.com/php/xxx.php', "type": "POST", "data": { 'selectedCustomerID': selectedCustomerID } } <?php $selectedCustomerID = $_POST["selectedCustomerID"]; include( "DataTables.php" ); use DataTables\Editor, DataTables\Editor\Field, DataTables\Editor\Format, DataTables\Editor\Mjoin, DataTables\Editor\Options, DataTables\Editor\Upload, DataTables\Editor\Validate; 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' ) ) ->where('invoice.CustID', $selectedCustomerID, '=') ->process( $_POST ) ->json();

This works okay.

I have

                buttons: [
            { extend: "create", editor: editorCustomer },
            { extend: "edit",   editor: editorCustomer },
            { extend: "remove", editor: editorCustomer }
        ]

When I click create I have

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

I get the error

TypeError: undefined is not an object (evaluating 'fields[ n ].set').
line 3504 column 14

What am I doing wrong here please ?

Cheers

Steve Warby

This question has an accepted answers - jump to answer

Answers

  • classic12classic12 Posts: 228Questions: 60Answers: 4
    Answer ✓

    I found the error.

    The error code is stating there is not a field there ( I think).

    I didn't have the field created in the editor.

    Cheers

    Steve Warby

This discussion has been closed.