server side per page restricting data.
server side per page restricting data.
rakesh_pathak
Posts: 11Questions: 1Answers: 0
Hi, i'm trying to make a server side request, want to restrict 25 row per page in data table.
have tried options- start, length, paging but no hope. can't 'LIMIT' the data in query as the database does not support.
This discussion has been closed.
Answers
Are you using pageLength?
https://datatables.net/reference/option/pageLength
You mean that your database does not support limit the results of the query? What database are you using?
Samir
Its a sybase database
.$( document ).ready(function() {
$('#backup_data').DataTable({
"bProcessing": true,
"serverSide": true,
"ajax":{
url :"response.php", // json datasource
type: "post", // type of method ,GET/POST/DELETE
//"start": 0,
//"length": 25,
error: function(){
$("#backup_data_processing").css("display","none");
}
},
"columns": [
{ "data": "StartDateTime"},
{ "data": "EndDateTime"},
{ "data": "JobDurationInMin"},
{ "data": "jobId"},
{ "data": "clientName"},
{ "data": "policyName"},
{ "data": "statusCode"},
{ "data": "status"},
{ "data": "ScheduleNames"}
]
});
});
Tangerine
Have tried all of them. but no luck.
`$( document ).ready(function() {
$('#backup_data').DataTable({
"bProcessing": true,
"serverSide": true,
"ajax":{
url :"response.php", // json datasource
type: "post", // type of method ,GET/POST/DELETE
//"start": 0,
//"length": 25,
error: function(){
$("#backup_data_processing").css("display","none");
}
},
"columns": [
});`
This Stack Overflow thread discusses some Sybase options for queries that support paging.
Kevin
Kevin, i have already tried with commands like 'TOP' and 'ROWCOUNT'. Here senario is bit different, its restricting the row per page but printing same result for other pages too i.e. the record remains the same . No new rows are displayed.
JSON DATA:--
{draw: "1", recordsTotal: 25, recordsFiltered: 10000,…}
draw: "1"
recordsTotal: 25
recordsFiltered: 10000
data: [{StartDateTime: "04/03/2020 04:30", EndDateTime: "04/03/2020 14:46", JobDurationInMin: "616",…},…]
0: {StartDateTime: "04/03/2020 04:30", EndDateTime: "04/03/2020 14:46", JobDurationInMin: "616",…}
StartDateTime: "04/03/2020 04:30"
EndDateTime: "04/03/2020 14:46"
JobDurationInMin: "616"
jobId: "8376149"
{draw: "2", recordsTotal: 25, recordsFiltered: 10000,…}
draw: "2"
recordsTotal: 25
recordsFiltered: 10000
data: [{StartDateTime: "04/03/2020 04:30", EndDateTime: "04/03/2020 14:46", JobDurationInMin: "616",…},…]
0: {StartDateTime: "04/03/2020 04:30", EndDateTime: "04/03/2020 14:46", JobDurationInMin: "616",…}
StartDateTime: "04/03/2020 04:30"
EndDateTime: "04/03/2020 14:46"
JobDurationInMin: "616"
jobId: "8376149"
As you can see, 2 draw same data.
The place to debug that is in your server script. Are you using a Datataables provided script or your own custom script? You will need to debug the query to make sure it is correct and fetching the expected data.
Kevin
Kevin
but its interesting, when i'm increasing page length from 10-25 data r coming properly. so its i guess problem with the paging.
Are you trying to use pagination with server side processing?
For example on the first load retrieve the first 25 records, if you click on the next page do another call to the backend and bring the next set of records.
Or you are trying to do a single call and retrieve the whole data and use client side pagination?
I had a similar issue with server side processing pagination.
This should be something you workaround in the backend, on the class you use for Datatables.
The following is the query that I build in the backend based on what I receive from the Datatables plugin.
It seems that Sybase has the ROW_NUMBER() function as well.
@SamirSilva exactly, i'm trying to achieve paging with server side processing .
Kevin here is my server side script(test)
<?php >` ?>`<?php
//include connection file
include_once("connection.php");