Default DataTables Editor Sort Order
Default DataTables Editor Sort Order
Dear All,
I would like to change the default order by (sort) to be descending so that new records are shown at the top. This is useful when creating new records and ideally you would want that record selected on the data table once created...
Please note that this is in reference to the Editor version and in particular the means to customize after using the generator... It seems to me the editor version is massively different..
I tried adding this to the table.<tablename>.js file:
order: [[ 0, "desc" ]]
however that does not work... I've looked through the code and documentation and for the life of me cannot find any examples of getting this to work... Basically how do you set the initialization options and where is a there a full list of parameters as this in principle should be easy...
Appreciate any inputs...
example code:
var table = $('#t_entities').DataTable( {
dom: 'Bfrtip',
ajax: 'assets/DataTablesEditor/php/table.t_entities.php',
columns: [
{
"data": "entity_name"
},
{
"data": "entity_url"
},
{
"data": "from_name"
},
{
"data": "from_email"
},
{
"data": "reply_name"
},
{
"data": "reply_email"
}
],
select: true,
lengthChange: false,
order: [[ 0, "desc" ]],
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor }
]
} );
} );
}(jQuery));
Answers
Actually my above code works!!!
The issue was due to web browser caching... Make sure to clear when developing as it can obscure changes...
Next thing to do is to figure out sorting on hidden fields as I note the generator for some reason leaves it out even when specified as a hidden item...