Closed oktoleong closed 10 years ago
Have you tried passing it in the settings?
public $components = array(
'DataTable.DataTable' => array(
'YourModel' => array('order' => ['id' => 'desc']),
....
)
);
Thanks tigrang I found a way to work around by removing / commenting out ID
public $components = array('Session','RequestHandler',
'DataTable.DataTable' => array(
'columns' => array(
//'id' => false,
...
),
),
);
By removing ID column it will make the records retrieved from DB sorted by ID = ASC (default mysql).
then add this line to datatable
$(document).ready(function() {
$('#example').dataTable( {
"order": [[ 3, "desc" ]]
} );
} );
Thanks for your help tigrang. Your plugin rocks :)
Thanks. Glad you got it working :)
I have looked through other similar issues but couldn't solve my problem.
I need to sort or order by mymodel.id DESC before processing to json format. This mymodel.id is not displayed in view
I open js debug tool and have a looked at my json data. it is not in order