Setting iDisplayStart when using ajax data only - version 1.7.5
Setting iDisplayStart when using ajax data only - version 1.7.5
raawr
Posts: 1Questions: 0Answers: 0
I have seen this issue pop up a couple times around the forum but not found that any of them seemed to fix the issue i was having.
I found that when setting iDisplayStart and using sAjaxSource/bProcessing data method, it would not set and kept resetting to zero. All other display configs, such as the iDisplayLength and oSearch worked fine.
To note as well here, I'm using datatables with a custom save(via aoDrawCallback) and load handle bypassing the native cookie handle built into datatables. This change might not be the best solution but it was the pin point to where it was going wrong for my use. I have not tested the effects of this change when using cookies but hope it might be useful for other people.
This is the snippet of code i used to initialize datatables.
[code]
var oTable;
args = {
"sPaginationType": "full_numbers",
"bProcessing":true,
"sAjaxSource":"/ajax_datatable",
"iDisplayStart":50,
"iDisplayLength":25
};
oTable = $('#tableid').dataTable(args);
[/code]
Note: I can not give a live example of this as I'm working on an in-house offline application.
After some trawling through the code i came across this function "_fnInitalise":
[code]
/* Reset the init display for cookie saving. We've already done a filter, and
* therefore cleared it before. So we need to make it appear 'fresh'
*/
oSettings.iInitDisplayStart = oSettings._iDisplayStart;
[/code]
This was resetting display start to zero in every case i attempted so i changed it to this to grab the value i was setting.
[code]
oSettings.iInitDisplayStart = oInit.iDisplayStart;
[/code]
I found that when setting iDisplayStart and using sAjaxSource/bProcessing data method, it would not set and kept resetting to zero. All other display configs, such as the iDisplayLength and oSearch worked fine.
To note as well here, I'm using datatables with a custom save(via aoDrawCallback) and load handle bypassing the native cookie handle built into datatables. This change might not be the best solution but it was the pin point to where it was going wrong for my use. I have not tested the effects of this change when using cookies but hope it might be useful for other people.
This is the snippet of code i used to initialize datatables.
[code]
var oTable;
args = {
"sPaginationType": "full_numbers",
"bProcessing":true,
"sAjaxSource":"/ajax_datatable",
"iDisplayStart":50,
"iDisplayLength":25
};
oTable = $('#tableid').dataTable(args);
[/code]
Note: I can not give a live example of this as I'm working on an in-house offline application.
After some trawling through the code i came across this function "_fnInitalise":
[code]
/* Reset the init display for cookie saving. We've already done a filter, and
* therefore cleared it before. So we need to make it appear 'fresh'
*/
oSettings.iInitDisplayStart = oSettings._iDisplayStart;
[/code]
This was resetting display start to zero in every case i attempted so i changed it to this to grab the value i was setting.
[code]
oSettings.iInitDisplayStart = oInit.iDisplayStart;
[/code]
This discussion has been closed.