Forum


00:05

10/08/2009

Hello Tony,
during answering on the question on the stackoverflow I found a bug in jqGrid. I posted small pragmatical fix in the pull request. One can use the demo to reproduce the problem. Another demo uses the suggested fix and it works (sorting and searching) correctly. Below I post the analyse of the problem.
The problem exist is one uses
localReader: {repeatitems: true}
option. In the case the items of data will be saved in the form in which are included in the input. For example like
{ id: "50", Â cell: ["test5", Â "2007-10-31", "300.00", "20.00", "320.00", "false", "FE", "note5"] }
The problem is that all parts of local sorting and local filtering/searching works incorrectly in the case. The reason are the calls
query.orderBy(ts.p.sortname,...)
see the lines of addLocalData. It uses ts.p.sortname as the first parameter (by parameter) of orderBy, which will be forwarded to orderBy (see the line) and so on. As the result the line
ab=by!==""?$.jgrid.getAccessor(v,by):v;
will be used with the name instead of the index in colModel (without taking in considerations cb, rn and subgrid columns). It's the reason why local sorting not works.
In the same way another line of addLocalData
query=compareFnMap[ts.p.postData.searchOper](query)(ts.p.postData.searchField,...);
uses ts.p.postData.searchField as the first parameter of compare functions. So the line
fld='jQuery.jgrid.getAccessor(this,\''+f+'\')';
will be used with f the as ts.p.postData.searchField which is the name of the corresponding field instead of the index. So searching will not work too.
Because of many possible other parts of the code I decided to suggest pragmatical and simple workaround: to modify the lines of code of addJSONData by adding the lines (see "else if" part)
if(locdata || ts.p.treeGrid===true){ rd[locid]= $.jgrid.stripPref(ts.p.idPrefix, idr); ts.p.data.push(rd); ts.p._index[rd[locid]]= ts.p.data.length-1; } else if(ts.p.datatype ==="local"&& dReader.repeatitems){ var idStripted = $.jgrid.stripPref(ts.p.idPrefix, idr), iData = ts.p._index[idStripted]; if(iData !==undefined&& ts.p.data !=null&& ts.p.data[iData]!=null){ $.extend(true, ts.p.data[iData], rd); } }
I think that close changes could be required in addXmlData (see here).
13:35

Moderators
30/10/2007

Hello Oleg,
Â
Thanks. I have merged the fix. Now going to publish a bug fix release next week.
Â
Best Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
50 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66