row selection example with server-side does nothing?
row selection example with server-side does nothing?
mihomes
Posts: 165Questions: 23Answers: 0
Curious as to what the problem here is as the console appears to be showing correct data yet no class is applied to any selected rows nor is the checkmark set.
"rowCallback": function( row, data, displayIndex ) {
console.log(data.DT_RowId);
console.log(row);
console.log(selected);
if ( $.inArray(data.DT_RowId, selected) !== -1 ) {
$(row).addClass('active').find('.checkboxes').attr("checked", true);
}
},
console shows the following :
122
<tr id="122" class="odd" role="row">
["122"]
on the flipside if I do the following in the drawcallback instead it works...
"drawCallback": function() {
$.each( selected, function ( i, id ) {
$('#datatable #'+id).addClass('active').find('.checkboxes').attr("checked", true);
});
},
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Can you post a link to a test case showing the issue please? I've just tried a simple example and it works as expected: http://live.datatables.net/zasuved/1/edit .
Allan
I figured out the problem.
My example does not work because my DT_RowId's are integers. Appending 'ID_' to them and my example works.
The downside... all processing scripts for the db now need to be edited to reflect that change.
An HTML ID can't start with a number - sounds like the browser might be enforcing that constraint!
Allan
New problem... cannot get a class applied to the newly created tr row. Does this have anything to do with being in a callback and/or being a child row?
I have no idea why the markdown is not working properly on that code block.