+
{filterList:fcol}
was added to theajaxUrl
in version 2.6.
@@ -166,33 +161,65 @@
- This update to the pager plugin that interacts with a database via ajax was added in version 2.0.32 and can be applied to the original tablesorter.
- The
ajaxUrl
andajaxProcessing
function are both required options for this interaction to work properly. - The
ajaxUrl
contains a replaceable string to sent the requested page ({page}
), block size ({size}
) or sort order ({sortList:name}
).
- - The
ajaxProcessing
function must* return the data in the following format[ total, rows, headers ]
- Modified in 2.1.3: + - The
ajaxProcessing
function is needed to convert your custom JSON format into an array usable by the pager plugin (modified in 2.1.3)
+
+ So, given this custom JSON format (this is only an example): +{ + "total_rows": 80, + + "headers" : [ + "ID", "Name", "Country Code", "District", "Population" + ], + + "rows" : [{ + "ID": 1, + "Name": "Kabul", + "CountryCode": "AFG", + "District": "Kabol", + "Population": 1780000 + }, { + "ID": 2, + "Name": "Qandahar", + "CountryCode": "AFG", + "District": "Qandahar", + "Population": 237500 + }, { + ... + }, { + "ID": 25, + "Name": "Haarlemmermeer", + "CountryCode": "NLD", + "District": "Noord-Holland", + "Population": 110722 + }] +}
TheajaxProcessing
function must* return the data in the following format[ total, rows, headers (optional) ]
, or in version 2.9+[ rows, total, headers (optional) ]
:[ // total # rows contained in the database - 100, + 80, // row data: array of arrays; each internal array has the table cell data for that row [ - [ "row1cell1", "row1cell2", ... "row1cellN" ], // first row - [ "row2cell1", "row2cell2", ... "row2cellN" ], // second row + [ 1, "Kabul", "AFG", "Kabol", 1780000 ], // [ "row1cell1", "row1cell2", ... "row1cellN" ], + [ 2, "Qandahar", "AFG", "Qandahar", 237500 ], // [ "row2cell1", "row2cell2", ... "row2cellN" ], ... - [ "rowNcell1", "rowNcell2", ... "rowNcellN" ] // last row + [ 25, "Haarlemmermeer", "NLD", "Noord-Holland", 110722 ] // [ "rowNcell1", "rowNcell2", ... "rowNcellN" ] ], - // header text (optional) - [ "Header1", "Header2", ... "HeaderN" ] + [ "ID", "Name", "Country Code", "District", "Population" ] // [ "Header1", "Header2", ... "HeaderN" ] (optional) ]
- The table header and footer text will be updated to match the JSON "header column #" text; but there is an issue with the table rendering improperly if the number of columns in the HTML and the number of columns in the JSON don't match.
- Limitations of this demo:
-
-
- This demo will not work in Chrome due to restrictions with browser and desktop interaction. +
- This demo will not work when viewing it locally due to communication restrictions between the browser and your desktop.
- The record size is limited to 25 records because this demo is not interacting with an actual database, but with four JSON files containing 25 records each.
* If you have a different JSON format and need help with the processing code, please ask the question on StackOverflow or message me directly (gmail; wowmotty). Please don't open an issue for help with code.
- +* If you have a different JSON format and need help with the processing code, please ask the question on StackOverflow or message me directly (gmail; wowmotty). Please don't open an issue for help with code.
+Demo
- +Original Ajax url:+Current Ajax url: +