-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filteredRows #576
Comments
Hi @ric79! If your ajax is returning data with output: '{startRow} - {endRow} | {myfilteredRows} [ {totalRows} ]', |
I read that issue and changed the code without luck. I'm using bootstrap theme as your example I mean, if ajaxProcessing is only returing total_rows and data, how can tablesorter know the myfilteredRows value? ...
ajaxProcessing: function (ajax) {
$('#loadingModal').modal('hide');
ajax = {
"data": [
[9, "AA", "BB", "CC"],
[10, "AA", "BB", "CC"],
[11, "AA", "BB", "CC"]
],
"myfilteredRows": 3,
"total_rows": 100
};
if (ajax && ajax.hasOwnProperty('data')) {
console.log(ajax.myfilteredRows);
return [ajax.total_rows, ajax.data ];
}
},
container: $(".pppp_ts-pager"),
cssGoto: ".pppp_pagenum",
output: '{startRow} - {endRow} | {myfilteredRows} [ {totalRows} ]',
... Whith this code in page myfilteredRows = 0 |
It depends on how you return data from the Sorry, but the object does need to follow this format (use "rows" instead of "data" and "total" instead of "total_rows") ajax = {
"rows": [
[9, "AA", "BB", "CC"],
[10, "AA", "BB", "CC"],
[11, "AA", "BB", "CC"]
],
"myfilteredRows": 3,
"total": 100
};
if (ajax && ajax.hasOwnProperty('rows')) {
return ajax;
} I think I better update the docs to make this more clear! |
Ok, now it's working. But the number of pages is still 10 (with pagination 10 rows per page). It seems to me that I have to rewrite in this way: ...
ajaxProcessing: function (ajax) {
$('#loadingModal').modal('hide');
ajax = {
"rows": [
[9, "AA", "BB", "CC"],
[10, "AA", "BB", "CC"],
[11, "AA", "BB", "CC"]
],
"originalTotal": 100,
"total": 3
};
if (ajax && ajax.hasOwnProperty('rows')) {
return ajax;
}
},
container: $(".pppp_ts-pager"),
cssGoto: ".pppp_pagenum",
output: '{startRow} - {endRow} | {totalRows} [ {originalTotal} ]',
... Paging is then ok. |
If you want to return rows or headers (optional), they must be named within the returned object as "rows" and "headers". The total number of pages is required, and must be named "total": {
// optional, but if included, it MUST be named "headers"
"headers" : [ "Numbers", "Value 1", "Value 2", "Value 3" ],
// optional, but if included, it MUST be named "rows"
"rows": [
[9, "AA", "BB", "CC"],
[10, "AA", "BB", "CC"],
[11, "AA", "BB", "CC"]
],
// required value "total"
"total": 100,
// everything else is optional and will be available in the "output" setting
"myfilteredRows": 3
} If you can't change the returned ajax from the server, you can just reassign the names within the ajaxProcessing function: ajaxProcessing: function (ajax) {
if (ajax && ajax.hasOwnProperty('rows')) {
ajax.total = ajax["total_rows"];
return ajax;
}
} |
Ok, thanks!!! |
Hello Mottie,
I'm filtering, sorting and paging server side
In JS
The output is
output: '{startRow} - {endRow} | {filteredRows} [ {totalRows} ]',
How can I update {filteredRows} using ajax.myfilteredRows?
Riccardo
The text was updated successfully, but these errors were encountered: