issues with bSaveState and server side processing
issues with bSaveState and server side processing
pmi
Posts: 1Questions: 0Answers: 0
Hi,
** EDIT ** Just found same bug report here: http://datatables.net/forums/comments.php?DiscussionID=1523&page=1 Sorry.
First of all - DataTables is the greatest :) Thank you Allan!
Still, I have a problem with saving paging state when server side processing is enabled.
Description:
Say, I have 26 rows in my table and page length is set to 10. Now I:
1. select 3rd page
-> info says: Showing 21 to 26 of 26 entries
2. click some other link leaving the site with my table
3. return to the site with my table
-> info says: Showing 21 to 30 of 26 entries (Bug #1) and
-> table shows rows 1 to 10 instead of 21 to 26 (Bug #2)
Searching for fix:
I'm far from being proficient with js and even further from knowing DataTables code well, but after hour of debugging I've found something:
1. Instead of:
[code]
this.fnDisplayEnd = function() {
if (this.oFeatures.bServerSide) {
return this._iDisplayStart + this.aiDisplay.length;
} else {
return this._iDisplayEnd;
}
};
[/code]
I'd put:
[code]
this.fnDisplayEnd = function() {
if (this.oFeatures.bServerSide) {
if (this._iDisplayStart + this.aiDisplay.length < this._iRecordsTotal) {
return this._iDisplayStart + this.aiDisplay.length;
}
else {
return this._iRecordsTotal;
}
} else {
return this._iDisplayEnd;
}
};
[/code]
2. In function _fnFilterComplete(oSettings, oInput, iForce):
[code]
oSettings._iDisplayStart = 0;
[/code]
this line is responsible for problems. It cannot be removed though as filtering depends on it now.
BR,
Pawel Iwaszko
** EDIT ** Just found same bug report here: http://datatables.net/forums/comments.php?DiscussionID=1523&page=1 Sorry.
First of all - DataTables is the greatest :) Thank you Allan!
Still, I have a problem with saving paging state when server side processing is enabled.
Description:
Say, I have 26 rows in my table and page length is set to 10. Now I:
1. select 3rd page
-> info says: Showing 21 to 26 of 26 entries
2. click some other link leaving the site with my table
3. return to the site with my table
-> info says: Showing 21 to 30 of 26 entries (Bug #1) and
-> table shows rows 1 to 10 instead of 21 to 26 (Bug #2)
Searching for fix:
I'm far from being proficient with js and even further from knowing DataTables code well, but after hour of debugging I've found something:
1. Instead of:
[code]
this.fnDisplayEnd = function() {
if (this.oFeatures.bServerSide) {
return this._iDisplayStart + this.aiDisplay.length;
} else {
return this._iDisplayEnd;
}
};
[/code]
I'd put:
[code]
this.fnDisplayEnd = function() {
if (this.oFeatures.bServerSide) {
if (this._iDisplayStart + this.aiDisplay.length < this._iRecordsTotal) {
return this._iDisplayStart + this.aiDisplay.length;
}
else {
return this._iRecordsTotal;
}
} else {
return this._iDisplayEnd;
}
};
[/code]
2. In function _fnFilterComplete(oSettings, oInput, iForce):
[code]
oSettings._iDisplayStart = 0;
[/code]
this line is responsible for problems. It cannot be removed though as filtering depends on it now.
BR,
Pawel Iwaszko
This discussion has been closed.