AliDatatableBundle
AliDatatableBundle copied to clipboard
how to use datatables advanced options with js functions
Is it possible to use more advanced options like this code:
$(document).ready(function() {
$('#example').DataTable( {
"columnDefs": [
{
// The `data` parameter refers to the data for the cell (defined by the
// `data` option, which defaults to the column being worked with, in
// this case `data: 0`.
"render": function ( data, type, row ) {
return data +' ('+ row[3]+')';
},
"targets": 0
},
{ "visible": false, "targets": [ 3 ] }
]
} );
} );
At the moment it collides with twig.
@greg606 I was searching for the exact same thing this morning because I wanted to use the aoColumnDefs option. Here's what I ended up doing in twig.
Hope this helps
{{ datatable({
'id' : id,
'js' : {
'destroy' : true,
'sAjaxSource' : path(ajaxSource),
'dom': '<"pull-right"ri><t><"pull-right"p>',
'iDisplayLength' : 15,
'bProcessing' : false,
'aoColumnDefs': [
{ targets: [0], visible: false},
{ targets: '_all', visible: true }
],
'fnPreDrawCallback': 'function( e ) {
if($("#modal-lookup-suppliers").hasClass("in")||$("#modal-lookup-customers").hasClass("in")){
$("#modal-loading").modal("show");
}
}',
'fnDrawCallback': 'function( e ) {
$("#modal-loading").modal("hide");
}'
}
}) }}
@sfauch1 Thanks, I will check it ;)