Reputation: 152
My point is... i have a dataTable with over 20k records, so i'm server side processing it, so the user browser stays sharp.
But, i have buttons i must 'assembly' to edit, remove or activate some records, and when i try to put html on the return of the server side processing, i get an error from dataTable, even if my json is well formatted...
so, what can i do?
I've tried using fnDrawCallback, but it runs after the data placement on the table.
Thanks in advance, Jorge Ferrari.
Upvotes: 1
Views: 2876
Reputation: 4918
If I understand correctly, you can build html controls using mRender in your column definitions. I have used this to create edit links on each datatable row using a value returned by the json data as a dynamic parameter:
'aoColumns': [
{
'mRender': function (data, type, row) {
var EditLinkText = ' |<a href=\'Edit/' + row[10] + '\'>Edit</a>';
return EditLinkText;
}
}
]
Upvotes: 2
Reputation: 152
I just find out how i may do it.
i can use the fnServerData.. here's an example
// POST data to server
$(document).ready( function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "xhr.php",
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
} );
} );
Upvotes: 1