1 to NaN of {COUNT} issue
1 to NaN of {COUNT} issue
Find on DataTables 1.10.12 version.
When u load datatable with preselected lentgth as "All", and with server side.
Smth like:
> var dt = $('#dt').DataTable({
> lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
> serverSide: true,
> searching: false,
> ordering: false,
> pageLength: -1,
> displayStart: 0,
> ajax: {
> url: "url"
> },
> language: {
> url: "/scripts/DataTables/dt.language.js"
> },
> columns: [
> { data: "memberNumber" },
> { data: "name" }
> ]
> });
in this case - it shows in info like "1 to NaN from 41" for example.
so i haven't found any info about it in discussion.
After that i goes to jquery.dataTables.js source and finde out issue in "fnDisplayEnd": function ();
so i've changed this function to:
"fnDisplayEnd": function ()
{
var
len = this._iDisplayLength,
start = this._iDisplayStart,
calc = start + len,
records = this.aiDisplay.length,
features = this.oFeatures,
paginate = features.bPaginate;
if (features.bServerSide) {
var minvalue = Math.min(start + len, this._iRecordsDisplay);
return paginate === false || len === -1 ?
start + records :
minvalue ? minvalue : this._iRecordsDisplay;
}
else {
return ! paginate || calc>records || len===-1 ?
records :
calc;
}
},
and now it works nice for me.
So question - is it a datatables issue, or i used wrong properties at start?
Replies
Sounds like you haven't fully implemented server-side processing, although without a test case it is impossible to say for sure.
Allan
Sorry, I don't think so. Because it works when i changing count from select input, it works fine. Even i change from 10 to All, it shows correct number. And when i set (10,25,50, 35, any other number) in constructor (preselected), like in example - it works fine too.
But when i set -1 (for all) - it shows NaN.
Works okay here: http://live.datatables.net/tahojuta/1/edit .
As I say, I'd need a test case showing the issue, or possibly just the JSON returned by the server from the -1 request. My guess is that the information properties are not correct.
Allan
Hmm, okay. It return this:
{"draw":4,"recordsTotal":10,"recordsFiltered":10,"data":[..]}
Can't show data, it consists of private information
That looks okay. Can you modify my example to recreate the issue? As you can see, it should work. I'd really need a test case showing the issue to be able to offer any help.
Allan
Sorry. I find out solution and reason of this
I've load parameters from hash by function and they loads in string. So i just needed to parseInt them before datatable initialization.