Editing tables with array-based data
Editing tables with array-based data
Hi!
I'm trying to reproduce an error that came up while adding inline editing functionality to an existing project. The problem seems to be that the backend delivers data in array form instead of keys and values. This worked fine with DataTables previously, but now I'm having trouble understanding, why the following code produces Unable to find row identifier
as an error, whenever I click on a cell.
var editor;
$(function() {
editor = new $.fn.dataTable.Editor( {
ajax: {
url: "ajax_editor"
},
table: "#table-view",
fields: [ {
label: "First name:",
name: "0"
}, {
label: "Last name:",
name: "1"
}, {
label: "Position:",
name: "2"
}
],
idsrc: "0"
} );
// Activate an inline edit on click of a table cell
$('#table-view').on( 'click', 'tbody td:not(:first-child)', function (e) {
editor.inline( this );
} );
var table = $('#table-view').DataTable( {
dom: "Bfrtip",
columns: [
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
{ data: "0" },
{ data: "1" },
{ data: "2" }
],
rowId: '0',
select: {
style: 'os',
selector: 'td:first-child'
},
buttons: [
{ extend: "create", editor: editor },
{ extend: "edit", editor: editor },
{ extend: "remove", editor: editor }
],
data: [
[
"Tiger",
"Nixon",
"System Architect"
],
[
"Garrett",
"Winters",
"Accountant"
]
]
} );
});
By the way: I was trying to get the example code from the DataTables Documentation running in DataTables live, but I don't get to see the data.
This question has an accepted answers - jump to answer
Answers
Should be:
See
idSrc
. Javascript is case sensitive.Allan
Ouch!
Thanks, I guess that means I can go solve my real problem now...