How to limit loaded data?
How to limit loaded data?
Haris Frane
Posts: 3Questions: 1Answers: 0
I'm new to datatables and I can't seem to figure out how to limit the load of data in the datatable with server size processing.
Ex: Load 200 rows from 500,000 rows. When it reaches the last row, it would reload the next set of rows making it 200 to 400 rows
I'm using ruby on rails and this is my current DataTable setup:
$(document).ready(function(){
var table = $("#tbl_server_side").DataTable({
"serverSize": true,
"processing": true,
"deferRender": true,
"ajax": {
"url": '/item_json',
"type": 'GET',
},
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"columns": [
{"data": "id"},
{"data": "item_origin"},
{"data": "itemable_id"},
{"data": "category"},
{"data": "spec.name"},
{"data": "spec.brand"},
{"data": "spec.model"},
{"data": "spec.frame_size"},
{"data": "spec.wheel_size"},
{"data": "color"},
{"data": "quantity"},
{"data": "cost"},
{"data": "price"},
],
});
$('select').formSelect();
});
This discussion has been closed.
Answers
You misspelt
serverSide
on line 3, so that would mean you'd be getting all the data at once. Hopefully fixing that will sort you out.Colin
Oh missed that thanks. Can you help me figure out how to set the data source from url from this example
https://datatables.net/extensions/scroller/examples/initialisation/server-side_processing
referencing from my setup:
"ajax": {
"url": '/item_json',
"type": 'GET',
},
Solved it. I'm using ruby on rails and got it to working with:
https://github.com/jbox-web/ajax-datatables-rails
My next problem is extending specs model to items