-
Notifications
You must be signed in to change notification settings - Fork 48
Support for DT_RowId #27
Comments
Can you link to the dataTables documentation on DT_RowId? |
Any idea or direction you could point me to fix this myself? |
Sorry man I don't really use this anymore, because I don't program on Cake2 applications anymore :-( If you have code you want to commit into this project I can make you a collaborator. |
Not a problem at all.. I will look into fixing it and commit. Thanks Chris. On Thu, Jan 22, 2015 at 12:26 AM, Chris Nizzardini <notifications@github.com
|
@AshHimself Did you manage to make any progress with this? |
Hey @jammy-git Looks like dataTables itself only lets you use DT_RowID with a flat array. You can define what field you would like DT_RowID to lookup but only in with the Editor license. My solution was to apply the id to the row using "fnRowCallback". This issue can be close
|
Thanks for the rapid response! I came up with a slightly different solution in the end. In getResponse, from line 163:
|
Fantastic, I'll defiantly give your code a test when I get home as this will save me from having to define the callback in each DataTable! |
No problem. Obviously it's not very flexible as it forces the use of the 'id' field for the Model to be the DT_RowId, but I figure in 99% of use cases that's what you'd want anyway. I'm using DataTables 1.9.4 and Editor 1.2.4 and it seems to work OK - the editor passes the correct id through via the Create and Edit AJAX calls at least. I think the best way to do this would be to specify a "dtRowIdField" as a property of the DataTableComponent, then have the component alter the conditions of the query and have the DB return DT_RowId as part of the query results. Think that would be slightly less overhead than altering $response in a loop - especially for larger datasets! |
And after all that, I go back and look at the documentation this morning and find the idSrc property! |
I was just about to tell you that :) Sadly, its only available in the editor plugin. |
Is it possible to implement the datatables option DT_RowId with cakephp-datatable?
The only way I was able to get it to work was to add the following code to the component. Though the side effect for this was that linkable then no longer worked.
Added to the getResponse function;
$removeName = Configure::read('current_controller');
$removeName = rtrim($removeName, "s");
$response = Set::extract('/' . $removeName . '/.', $response);
Datatables documentation as follows; http://datatables.net/release-datatables/examples/server_side/ids.html
The text was updated successfully, but these errors were encountered: