3.2.0

Server side sorting and paging

I'm attempting to implement server side paging which means that sorting also has to uccur on the server side. I browsed this forum and found out that I can "override" the client side sort with my own logic so I wrote the following. Owever, when my "SortFunction" is invoqued, it complains that setURL is not valid:

var iCurrentSortIndex = 0;
var strCurrentSortDir = "";
var iCurrentPage = 1;
var SortFunction = function(src){
var iSortIndex = src.getProperty("item/index");
var strSortDir = src.getProperty("sort/direction");
if (iSortIndex != iCurrentSortIndex) { strSortDir = "ascending";
} else if (strCurrentSortDir == "descending") { strSortDir = "ascending";
} else { strSortDir = "descending"; }
this.setProperty("sort/index", iSortIndex);
this.setProperty("sort/direction", strSortDir);
var strURL = "FetchData.aspx?pageNumber=" + iCurrentPage;
strURL += "&sortBy=" + iCurrentSortIndex;
strURL += "&sortDir=" + strCurrentSortDir;
this.setURL(strURL);
this.request();
iCurrentSortIndex = iSortIndex;
strCurrentSortDir = strSortDir;
};
obj.setAction("columnSort", SortFunction);
February 7,
In this case setURL and request are methods of the external data model and not the grid itself, so you should call them like this:

table.setURL(...);
table.request();

where table is your XML data source (Active.XML.Table).
Alex (ActiveWidgets)
February 10,
How do I get a reference to table from within "SortFunction"? Can I do something like "this.table.seuURL(...)"?
February 10,
var table = this.getModel("data");
Alex (ActiveWidgets)
February 10,
Perhaps paging could be better done using some sort of framework (jsrs)
http://www.ashleyit.com/rs/

turkish
July 26,
Basically all I do is load the initial htm page then I just use XMLHttpRequest to retrieve data as needed I work in 16 row blocks so I can cache the data localy. I use a perl script running under mod_perl (essential for speed) which I pass my query + sort order and the row position I want data from and number of rows, I don't use page since then a client could choose page size if it wanted. I send data back in TSV since this format will always be ok with my source data I don't use xml because it would make large files but this does have the side effect of making parsing data quick client side as well. When I sort all I do is erase my cache since this will cause the client to load data again.

July 27,

This topic is archived.

See also:


Back to support forum