Paging info incorrect

Paging info incorrect

ashwinashwin Posts: 4Questions: 0Answers: 0
edited October 2011 in Bug reports
This is a problem that we found in version 1.7.2 of datatables, which still resides in version 1.8.2.

Sometimes the information send to datatables happens to be in the incorrect format.

We found that the positioning information were not always in Integer format, but in String format.
This would lead "0"+1 to become 01 instead of 1 and "20"+10 to become 2010 instead of 30.

This problem can be resolved by putting parseInt on the correct places.

Note that i have used the minified version of dataTables

I changed the following parts in version 1.8.2 te correct this behaviour:

[code]
this.fnDisplayEnd = function () {
return this.oFeatures.bServerSide ? this.oFeatures.bPaginate === false || this._iDisplayLength == -1 ? this._iDisplayStart + this.aiDisplay.length : Math.min(this._iDisplayStart + this._iDisplayLength, this._iRecordsDisplay) : this._iDisplayEnd
};[/code]
to
[code]
this.fnDisplayEnd = function () {
return this.oFeatures.bServerSide ? this.oFeatures.bPaginate === false || parseInt(this._iDisplayLength) == -1 ? parseInt(this._iDisplayStart) + this.aiDisplay.length : Math.min(parseInt(this._iDisplayStart) + parseInt(this._iDisplayLength), parseInt(this._iRecordsDisplay)) : this._iDisplayEnd };
[/code]

and

[code]
function Ra(a) {
if (!(!a.oFeatures.bInfo || a.aanFeatures.i.length === 0)) {
var b = a._iDisplayStart + 1,
c = a.fnDisplayEnd(),
d = a.fnRecordsTotal(),
f = a.fnRecordsDisplay(),
e = a.fnFormatNumber(b),
h = a.fnFormatNumber(c),
j = a.fnFormatNumber(d),
k = a.fnFormatNumber(f);
if (a.oScroll.bInfinite) e = a.fnFormatNumber(1);
e = a.fnRecordsDisplay() === 0 && a.fnRecordsDisplay() == a.fnRecordsTotal() ? a.oLanguage.sInfoEmpty + a.oLanguage.sInfoPostFix : a.fnRecordsDisplay() === 0 ? a.oLanguage.sInfoEmpty + " " + a.oLanguage.sInfoFiltered.replace("_MAX_", j) + a.oLanguage.sInfoPostFix : a.fnRecordsDisplay() == a.fnRecordsTotal() ? a.oLanguage.sInfo.replace("_START_", e).replace("_END_", h).replace("_TOTAL_", k) + a.oLanguage.sInfoPostFix : a.oLanguage.sInfo.replace("_START_", e).replace("_END_", h).replace("_TOTAL_", k) + " " + a.oLanguage.sInfoFiltered.replace("_MAX_", a.fnFormatNumber(a.fnRecordsTotal())) + a.oLanguage.sInfoPostFix;
if (a.oLanguage.fnInfoCallback !== null) e = a.oLanguage.fnInfoCallback(a, b, c, d, f, e);
a = a.aanFeatures.i;
b = 0;
for (c = a.length; b < c; b++) i(a[b]).html(e)
}
}

[/code]

to

[code]
function Ra(a) {
if (!(!a.oFeatures.bInfo || a.aanFeatures.i.length === 0)) {
var b = parseInt(a._iDisplayStart) + 1,
c = a.fnDisplayEnd(),
d = a.fnRecordsTotal(),
f = a.fnRecordsDisplay(),
e = a.fnFormatNumber(b),
h = a.fnFormatNumber(c),
j = a.fnFormatNumber(d),
k = a.fnFormatNumber(f);
if (a.oScroll.bInfinite) e = a.fnFormatNumber(1);
e = a.fnRecordsDisplay() === 0 && a.fnRecordsDisplay() == a.fnRecordsTotal() ? a.oLanguage.sInfoEmpty + a.oLanguage.sInfoPostFix : a.fnRecordsDisplay() === 0 ? a.oLanguage.sInfoEmpty + " " + a.oLanguage.sInfoFiltered.replace("_MAX_", j) + a.oLanguage.sInfoPostFix : a.fnRecordsDisplay() == a.fnRecordsTotal() ? a.oLanguage.sInfo.replace("_START_", e).replace("_END_", h).replace("_TOTAL_", k) + a.oLanguage.sInfoPostFix : a.oLanguage.sInfo.replace("_START_", e).replace("_END_", h).replace("_TOTAL_", k) + " " + a.oLanguage.sInfoFiltered.replace("_MAX_", a.fnFormatNumber(a.fnRecordsTotal())) + a.oLanguage.sInfoPostFix;
if (a.oLanguage.fnInfoCallback !== null) e = a.oLanguage.fnInfoCallback(a, b, c, d, f, e);
a = a.aanFeatures.i;
b = 0;
for (c = a.length; b < c; b++) i(a[b]).html(e)
}
}
[/code]

------------------------------------
Environmental information:
OS: Windows 7 Ultimate x64
JQuery version: v1.6.4
Browser: tested on IE8, IE9 & FF6+
Datatables version: 1.7.2 & 1.8.2

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    edited October 2011
    [scratch that. read that you have the solution]
This discussion has been closed.