After inline editing entire table is refreshed

After inline editing entire table is refreshed

repziorepzio Posts: 2Questions: 1Answers: 0

After I do inline editing and submit onBlur and my data for that row is returned another AJAX call is automatically made and reloads the tables data which loses the persons position in the data table.

Here is my code:
editor = new $.fn.dataTable.Editor({
ajax: {
create: {
type: 'POST',
url: '/customers/dataTableAction'
},
edit: {
type: 'PUT',
url: '/customers/dataTableAction'
},
remove: {
type: 'DELETE',
url: '/customers/dataTableAction'
}
},
table: "#example",
idSrc: "CustomerID",
fields: [{
label: "CustomerNumber",
name: "CustomerNumber"
}, {
label: "",
name: "Name"
}, {
label: "",
name: "Address1"
}, {
label: "",
name: "City"
}, {
label: "",
name: "StateProvince"
}, {
label: "",
name: "RepNumber"
}
]
});

                editor.on('open', function (e, type) {
                    if (type === 'inline') {
                        // Listen for a tab key event when inline editing
                        $(document).on('keydown.editor', function (e) {
                            if (e.keyCode === 9) {
                                e.preventDefault();

                                // Find the cell that is currently being edited
                                var cell = $('div.DTE').parent();
                                if (e.shiftKey && cell.prev().length && cell.prev().index() !== 0) {
                                    // One cell to the left (skipping the first column)
                                    cell.prev().click();
                                }
                                else if (e.shiftKey) {
                                    // Up to the previous row
                                    cell.parent().prev().children().last(0).click();
                                }
                                else if (cell.next().length) {
                                    // One cell to the right
                                    cell.next().click();
                                }
                                else {
                                    // Down to the next row
                                    cell.parent().next().children().eq(1).click();
                                }
                            }
                        });
                    }
                })
                    .on('close', function () {
                        $(document).off('keydown.editor');
                    });


                // Activate an inline edit on click of a table cell
                $('#example').on('click', 'tbody td:not(:first-child)', function (e) {
                    editor.inline(this, {
                        submitOnBlur: true
                    });
                });

                $('#example').dataTable({
                    "serverSide": true,
                    "ajax": "/customers/_SelectBatchEditing",
                    "columns": [
                        { "data": "CustomerNumber" },
                        { "data": "Name" },
                        { "data": "Address1" },
                        { "data": "City" },
                        { "data": "StateProvince" },
                        { "data": "RepNumber" }
                    ],
                    "createdRow": function (row, data, index) {
                        $(row).append("<td><a href='/customers/edit/" + data.CustomerID + "' rel='facebox' title='Edit Customer: " + data.Name + "'><i class='fa fa-edit'></i></a></td>");
                    },
                     order: [ 1, 'asc' ],
                    "scrollY": "400px",
                    "scrollX": true,
                    "lengthMenu": [[50, 75, 100], [50, 75, 100]]
                });

Answers

This discussion has been closed.