-
11 Dec 2006 11:59 AM #1
Using a renderer on a column doesn't seem to work with sort?
Using a renderer on a column doesn't seem to work with sort?
I have a col with the value: float;#300.000000000000
I am using a renderer to return: '300'
After I do that, the column sort has no effect on the grid. So I guess my questiosn is does the sortType only refer to the dataModel, and not the rendered data?
I am using the following
Code:{header: "Avg Hours", width: 120, sortable: true, sortType: sort.asInt, renderer: this.renderTypeFloat},
-
11 Dec 2006 12:21 PM #2
Yes, but you could define a new sortType (other than asInt), which applies your renderer to the data.
Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
11 Dec 2006 12:32 PM #3
I'm confused as to whats going on? Can you explain further?
-
11 Dec 2006 12:41 PM #4
His data value looks like it's actually on object containing type and value. The renderer returns the value, but sort is probably treating the entire thing as a string so, it probably doesn't make sense if you sort 'float, 300' and 'int,200'.
Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
11 Dec 2006 12:41 PM #5
Hi Jack.
What I have is funky xml that i'm loading into the dataModel. One of the column values is represented as:
"float;#300.000000000000"
I am using a renderer function to convert this to "300" as an int:
Code:{header: "Approved Hours", width: 120, sortable: true,sortType: sort.asInt, renderer: this.renderTypeVariant}After doing the render, clicking the column header to sort as an integer does not do any sort at all.Code:renderTypeVariant : function(val){ if(val != '') return(parseInt(val.substring(val.indexOf('#')+1))); },
-
11 Dec 2006 12:50 PM #6
What you are looking for is preprocessor to reformat funky xml into a valid number. Something like:
The difference is this parses the data as it is coming in and then sort and renderers will both use the parsed value (rather than parsing and/or converting on every sort and/or render).Code:// add preprocessor to the second data column dataModel.addPreprocessor(2, function(value){ if(value != ''){ value = parseInt(value.substring(value.indexOf('#')+1), 10); } return value; });
-
11 Dec 2006 1:05 PM #7
That did the trick!! Thanks Jack. So on that note, when would you use a renderer instead of a pre-processor?
-
11 Dec 2006 1:32 PM #8
I would use a renderer when the data is in the correct format, but you want it rendered differently. For example, your data has the values 1, .5, 2.3, 4.5 and you want them rendered $1.00, $0.50, $2.30 etc. Or another example would be your data contains Date objects and you want them rendered as formatted strings.
Similar Threads
-
Problem with column sort
By yevgen in forum Ext 1.x: BugsReplies: 3Last Post: 2 Apr 2009, 2:32 AM -
Re-render content in resizable column using custom renderer?
By KimH in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 25 Jun 2008, 8:34 AM -
Grid: Post column name (not just id) in remote sort
By brondsem in forum Community DiscussionReplies: 2Last Post: 18 Feb 2007, 4:01 PM -
grid sort marks all rows by the first column
By lsmith in forum Ext 1.x: Help & DiscussionReplies: 8Last Post: 22 Nov 2006, 9:13 AM -
Grid Sort for formatted date column in FF vs IE6
By mrim in forum Ext 1.x: Help & DiscussionReplies: 5Last Post: 31 Oct 2006, 8:28 PM


Reply With Quote