Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Wrong sorting/filtering in case of localReader: {repeatitems: true}
24/07/2014
00:05
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

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). 
31/07/2014
22:31
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hello Tony,

I posted the improved pull request which fix the problem.

Best regards
Oleg

01/08/2014
13:35
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information