Editor not editing or inserting

Editor not editing or inserting

uneasyuneasy Posts: 1Questions: 1Answers: 0

Till that point I was always finding answer here. I decided to try table editor.
As a beginning I just copied example from basic example page, even data.

Everything works (ish), when I am trying to insert new row, there is no data validation like in example,
no matter what I type or even if I leave it empty, then press update, it comes back from modal and makes a copy of previous row.

Editing row, no mater what I change it comes back from modal and does nothing expect highlight the row.
Looks like I am missing something simple, but I have no errors in console as well.

Also I can't close modal window by pressing X, only by clicking outside modal.
Here is the code:

var editor;
   editor = new $.fn.dataTable.Editor( {
        ajax: "data.php",
        table: "#exampleTable",
        fields: [ {
                label: "Name:",
                name: "name"
            }, {
                label: "Position:",
                name: "position"
            }, {
                label: "Office:",
                name: "office"
            }, {
                label: "Extension:",
                name: "extn"
            }, {
                label: "Start date:",
                name: "start_date",
                type: "datetime"
            }, {
                label: "Salary:",
                name: "salary"
            }
        ]
    } );
    //$('#exampleTable').on( 'click', 'tbody td:not(:first-child)', function (e) {
    //     editor.bubble( this );
    //  } );
    var table = $('#exampleTable').DataTable( {
            dom: "Bfrtip",
            ajax: "data.php",
            select: true,
            columns: [
                        { data: "name" },
                        { data: "position" },
                        { data: "office" },
                        { data: "extn" },
                        { data: "start_date" },
                        { data: "salary", render: $.fn.dataTable.render.number( ',', '.', 0, '$' ) }
                    ],
           buttons: [
                        { extend: "create", editor: editor },
                        { extend: "edit", editor: editor },
                        { extend: "remove", editor: editor },

                    ],
        } );

});

And data:

{
  "data": [
    {
      "DT_RowId": "row_1",
      "name": "Nixon",
      "position": "System Architect",
      "email": "t.nixon@datatables.net",
      "office": "Edinburgh",
      "extn": "5421",
      "age": "61",
      "salary": "320800",
      "start_date": "2011-04-25"
    }
  ],
  "options": [],
  "files": []
}

Answers

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    What is inside your data.php file? It needs to write the new data to the database. We provide PHP libraries to help make that easier - see the documentation here.

    Allan

This discussion has been closed.