Server pagination - When i change page number i will fetches data but that will not to rerendered in
Server pagination - When i change page number i will fetches data but that will not to rerendered in
ezhil9841
Posts: 7Questions: 2Answers: 0
Hi all,
I am using data table with backbone JS. When first time loading of data table data which fetched from server is loaded. When i change page number or anything AJAX request will be called. It also fetched the data. But the the new data which is not rendered in view.
var table = $('#main_table');
dT = table.DataTable({
"ajax": { "url": url, "cache": false, "type": "POST" },
"columns": cols,
"serverSide": true,
"cache": false,
"processing": false,
"destroy": true,
"language": {
"emptyTable": "No data available in table",
"info": "Showing _START_ to _END_ of _TOTAL_ entries",
"infoEmpty": "No entries found",
"infoFiltered": "(filtered1 from _MAX_ total entries)",
"lengthMenu": "Show _MENU_ entries",
"search": "Search:",
"zeroRecords": "No matching records found",
search: "_INPUT_",
searchPlaceholder: "Search from below results.",
"paginate": {
"previous": "Prev",
"next": "Next",
last": "Last",
"first": "First"
}
},
"pageLength": 10,
"pagingType": "bootstrap_full_number",
"dom": "<'row'<'export-tool margin-right-10'>r><'table-scrollable't><'row'<'col-md-4 col-sm-12 margin-top-10'li><'col-md-8 col-sm-12 margin-top-10'p>>",
"order": orderDefault,
"fnDrawCallback": function (oSettings) {
$this.tableLoad = true;
var totalRecords = oSettings.fnRecordsTotal();
},
"createdRow": function (row, data, index) {
},
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You are using server side processing. Does your server script follow the SSP protocol described here:
https://datatables.net/manual/server-side
Do you get any alert messages or errors in the browser's console?
Please post the JSON response, from the browser's developer tools, you get for a page that doesn't display.
Kevin
Hi @ezhil9841 ,
That's the data going to the server, which looks fine. Does the server respond with the expected data? And as Kevin asked, are you seeing errors in the server scripts or in the browser's console?
Cheers,
Colin
I am getting my desired response from server. But my data is not rerendering my data.
Kevin
It would be worth looking at the
serverSide
protocol here. You're sayingrecordsTotal
is 19, but only 6 records are being returned (unless you're snipping the output). Also, this page here, on the Ajax tab, will show you how it looks in motion.Cheers,
Colin
Hi Colin,
I have gone through all the server side docs. When i try independantly which is working. When i try with backbone the new data will not be rendered in Datatable.
Hi @ezhil9841 ,
Check the browser's network tab for the Ajax request. You'll need to confirm what is being sent to the server is correct, and if it is, confirm that the return is correct. One of them must be wrong. If you can link to the page, or create a test case, we're happy to have a look. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
If you are trying to use backbonme.js with Datatables you might be interested in this thread and the thread it links to:
https://datatables.net/forums/discussion/comment/133532/#Comment_133532
You mentioned in this in your other thread.
When you say "data comes from server my call back is not called" what is the callback that is not called?
EDIT: You may want to look on SO for Datatables and backbone.js integration. There seems to be some threads there asking about this.
Kevin
I am using the below code to redraw the table.
"fnDrawCallback": function (oSettings) {
It will be called while loading the table first time. While changing the page number request will be triggered to server. Server returns set of data which will not rendered in table.
Hi @ezhil9841 ,
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin