Reputation: 6694
I have a large data table and I am trying to use DataTables to organize the data. I want to use their server side processing for pagination, search, etc but I'm not sure how. Their docs show:
$('#example').dataTable( {
"serverSide": true,
"ajax": "file.php" // or "ajax": "data.json"
});
but I am not sure what to pass as the file for my table? How to I pass my entire table? I'll happily give more information if my question is unclear.
Upvotes: 2
Views: 2696
Reputation: 191
When using server-side processing, DataTables sends a request to the path specified by that "ajax" property. For example, if you had a Book model, with a corresponding BooksController that responds properly to json requests, you'd have something like this assuming regular Rails resources routes:
$('#example').dataTable( {
"serverSide": true,
"ajax": "/books.json"
});
This would result in DataTables sending an Ajax request to your server, with search parameters as described here: http://datatables.net/manual/server-side
The "Configuration" section in the link above also has more information about setting the Ajax URL and settings.
Upvotes: 1