Support of client side pagination for xmlstring datatype:
I have been using jqgrid 3.4.1 in my project. The way I designed the project is as follows:
1. Get all data as an XML string at once
2. Load into multiple grid on the same UI
So, I used the local datatype:
datatype: 'xmlstring'
Since, the data became huge with time, the performance deteriorated. And since, there was no pagination support for local datatype, I decided to add one. I hope you find this useful and it can be easily added into jqGrid 3.6 with some simple changes. Since I did not have a chance to look at jqGrid versions post 3.4.1, I am providing the changes I made in 3.4.1 to support simple pagination that worked for me.
Here are the changes I made (highlighted in bold):
1. Added, following grid parameters to each grid where pagination was to be supported:
pagination: {startIndex: 0, maxRecordsPerPage: 10}
2. Updated function addXmlData in grid.base.js
var addXmlData = function addXmlData (xml,t, rcnt) {
if(xml) { var fpos = ts.p.treeANode || 0; rcnt=rcnt ||0; if(fpos===0 && rcnt===0) {$(”tbody tr:gt(0)”, t).remove();} } else { return; }
var v,row,gi=0,si=0,cbid,idn, getId,f=[],rd =[],cn=(ts.p.altRows === true) ? 'alt':'';
if(!ts.p.xmlReader.repeatitems) {f = reader(”xml”);}
if( ts.p.keyIndex===false) {
idn = ts.p.xmlReader.id;
if( idn.indexOf(”[“) === -1 ) {
getId = function( trow, k) {return $(idn,trow).text() || k;};
}
else {
getId = function( trow, k) {return trow.getAttribute(idn.replace(/[\[\]]/g,””)) || k;};
}
} else {
getId = function(trow) { return (f.length – 1 >= ts.p.keyIndex) ? $(f[ts.p.keyIndex],trow).text() : $(ts.p.xmlReader.cell+”:eq(”+ts.p.keyIndex+”)”,trow).text(); };
}
$(ts.p.xmlReader.page,xml).each(function() {ts.p.page = this.textContent
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top