Incorrect table length reported
Incorrect table length reported
andyleclair
Posts: 2Questions: 0Answers: 0
Hi!
I believe that I've found a bug in the number of records reported when using server-side processing.
I have a table with 110 total entries. If I start by viewing with a table length of 25, go to page 2, then set the viewable length to 100, I see in the footer "Showing 11 to 110 of 110 total entries." If I start on page 1, set the viewable length to 100, then go to page 2, I see the desired "Showing 100 to 110 total entries."
I'm reasonably sure that my server-side processing code is correct.
Here's my datatables initialization code, if that will help:
[code]
$('#NetworkTable').dataTable({
bProcessing: true,
bPaginate: true,
bServerSide: true,
sAjaxSource: '/'+brand()+'/network.json',
iDisplayLength: 25,
aLengthMenu: [[25,50,100], ['25', '50', '100']],
bSort: false,
sDom: "rtlip",
fnServerParams: function(aoData) {
var settings = $('#NetworkTable').dataTable().fnSettings();
var pg = Math.ceil(settings['_iDisplayStart'] / settings['_iDisplayLength']) + 1;
aoData.push({ name: "page", value: pg });
},
oLanguage: {
sProcessing: "",
sZeroRecords: "No results found."
}
});
[/code]
I believe that I've found a bug in the number of records reported when using server-side processing.
I have a table with 110 total entries. If I start by viewing with a table length of 25, go to page 2, then set the viewable length to 100, I see in the footer "Showing 11 to 110 of 110 total entries." If I start on page 1, set the viewable length to 100, then go to page 2, I see the desired "Showing 100 to 110 total entries."
I'm reasonably sure that my server-side processing code is correct.
Here's my datatables initialization code, if that will help:
[code]
$('#NetworkTable').dataTable({
bProcessing: true,
bPaginate: true,
bServerSide: true,
sAjaxSource: '/'+brand()+'/network.json',
iDisplayLength: 25,
aLengthMenu: [[25,50,100], ['25', '50', '100']],
bSort: false,
sDom: "rtlip",
fnServerParams: function(aoData) {
var settings = $('#NetworkTable').dataTable().fnSettings();
var pg = Math.ceil(settings['_iDisplayStart'] / settings['_iDisplayLength']) + 1;
aoData.push({ name: "page", value: pg });
},
oLanguage: {
sProcessing: "",
sZeroRecords: "No results found."
}
});
[/code]
This discussion has been closed.
Replies
Request 1, page: 1, length: 25
[code]
{"sEcho"=>"3", "iColumns"=>"7", "sColumns"=>"", "iDisplayStart"=>"0", "iDisplayLength"=>"25", "mDataProp_0"=>"0", "mDataProp_1"=>"1", "mDataProp_2"=>"2", "mDataProp_3"=>"3", "mDataProp_4"=>"4", "mDataProp_5"=>"5", "mDataProp_6"=>"6", "sSearch"=>"", "bRegex"=>"false", "sSearch_0"=>"", "bRegex_0"=>"false", "bSearchable_0"=>"true", "sSearch_1"=>"", "bRegex_1"=>"false", "bSearchable_1"=>"true", "sSearch_2"=>"", "bRegex_2"=>"false", "bSearchable_2"=>"true", "sSearch_3"=>"", "bRegex_3"=>"false", "bSearchable_3"=>"true", "sSearch_4"=>"", "bRegex_4"=>"false", "bSearchable_4"=>"true", "sSearch_5"=>"", "bRegex_5"=>"false", "bSearchable_5"=>"true", "sSearch_6"=>"", "bRegex_6"=>"false", "bSearchable_6"=>"true", "page"=>"1", "_"=>"1340305484718"}
[/code]
Request 2, page: 2 length: 25
[code]
{"sEcho"=>"4", "iColumns"=>"7", "sColumns"=>"", "iDisplayStart"=>"25", "iDisplayLength"=>"25", "mDataProp_0"=>"0", "mDataProp_1"=>"1", "mDataProp_2"=>"2", "mDataProp_3"=>"3", "mDataProp_4"=>"4", "mDataProp_5"=>"5", "mDataProp_6"=>"6", "sSearch"=>"", "bRegex"=>"false", "sSearch_0"=>"", "bRegex_0"=>"false", "bSearchable_0"=>"true", "sSearch_1"=>"", "bRegex_1"=>"false", "bSearchable_1"=>"true", "sSearch_2"=>"", "bRegex_2"=>"false", "bSearchable_2"=>"true", "sSearch_3"=>"", "bRegex_3"=>"false", "bSearchable_3"=>"true", "sSearch_4"=>"", "bRegex_4"=>"false", "bSearchable_4"=>"true", "sSearch_5"=>"", "bRegex_5"=>"false", "bSearchable_5"=>"true", "sSearch_6"=>"", "bRegex_6"=>"false", "bSearchable_6"=>"true", "page"=>"2", "_"=>"1340305566333"}
[/code]
Request 3, page: 2, length: 100
[code]
{"sEcho"=>"5", "iColumns"=>"7", "sColumns"=>"", "iDisplayStart"=>"10", "iDisplayLength"=>"100", "mDataProp_0"=>"0", "mDataProp_1"=>"1", "mDataProp_2"=>"2", "mDataProp_3"=>"3", "mDataProp_4"=>"4", "mDataProp_5"=>"5", "mDataProp_6"=>"6", "sSearch"=>"", "bRegex"=>"false", "sSearch_0"=>"", "bRegex_0"=>"false", "bSearchable_0"=>"true", "sSearch_1"=>"", "bRegex_1"=>"false", "bSearchable_1"=>"true", "sSearch_2"=>"", "bRegex_2"=>"false", "bSearchable_2"=>"true", "sSearch_3"=>"", "bRegex_3"=>"false", "bSearchable_3"=>"true", "sSearch_4"=>"", "bRegex_4"=>"false", "bSearchable_4"=>"true", "sSearch_5"=>"", "bRegex_5"=>"false", "bSearchable_5"=>"true", "sSearch_6"=>"", "bRegex_6"=>"false", "bSearchable_6"=>"true", "page"=>"2", "_"=>"1340305576709"}
[/code]
What's interesting to note here is that on the third request, iDisplayStart is incorrectly being set to 10 instead of 100.