-
8 Dec 2010 12:12 PM #1
[OPEN-1449] Problem with sorting column with undefined values in grid.
[OPEN-1449] Problem with sorting column with undefined values in grid.
I recently found problem with grid/store: I'm receiving data from server and some fields could be null. Then when I tried to sort grid by the fields, it was displaying in some weired way.
So I dug in the source code and found out that Store does not handle 'undefined' values.
Here is my version of the sort function:
Code:Ext.override(Ext.data.Store,{createSortFunction:function(field, direction) { direction = direction || "ASC"; var directionModifier = direction.toUpperCase() == "DESC" ? -1 : 1; var sortType = this.fields.get(field).sortType; //create a comparison function. Takes 2 records, returns 1 if record 1 is greater, //-1 if record 2 is greater or 0 if they are equal return function(r1, r2) { var v1 = sortType(r1.data[field]), v2 = sortType(r2.data[field]); if (v1 && !v2){ return directionModifier*1; } if (!v1 && v2){ return directionModifier*-1; } return directionModifier * (v1 > v2 ? 1 : (v1 < v2 ? -1 : 0)); }; }});
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
Sorting Scientific values and Decimals in a Grid column
By parit in forum Ext GWT: DiscussionReplies: 4Last Post: 31 May 2010, 6:31 AM -
this.fields is undefined in store.sort after sorting grid column
By bradlymathews in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 23 Mar 2009, 3:50 PM -
Problem: Grid only remorte sorting on first column.
By CrAiG_mC in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 12 Feb 2009, 7:00 AM -
Disable column onclick sorting, but still allow sorting via column menu
By Troy Wolf in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 26 Mar 2008, 9:39 AM -
Grid Sorting does not properly orders the values.
By Sandeep in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 16 Sep 2007, 10:27 PM


Reply With Quote