PDA

View Full Version : Local Sorting in Grid Column: how to fix it



amaunz
1 Mar 2013, 10:51 PM
Hi, I generate my Ext.grid.Panel using Netzke (http://netzke.org/), and I have not learned ExtJS from the bottom up. Here is the problem: I have disabled remote sorting on my grid, and most of my columns now sort numerically, while some sort alphanumerically (i.e. 10<2 for example). But ALL columns contain numerical data only and therefore should sort numerically! :((

I am sure this has something to do with how Netzke generates the columns (the affected ones are 'virtual' columns), but I would like to fix that on the client side first. Also, enabling remote sorting is not an option. I have now already waisted a lot of time to find out how to fix the sorters for the affected columns, with no success. Any help would be much appreciated.

I am using version 4.1.x of ExtJS.

mitchellsimoens
4 Mar 2013, 8:24 AM
Do you have a type set on the model field?

amaunz
5 Mar 2013, 6:27 AM
Do you have a type set on the model field?

Probably that is what Netzke is missing. Could you indicate how to do it? What do I need to do after having set the type?

Thanks so much!

mitchellsimoens
5 Mar 2013, 7:42 AM
If the data is coming in as a string and you don't have a type on the field in the model then it will think it's just a string. Setting type to 'int' will convert it to an integer allowing the sorting to be numeric.

amaunz
10 Mar 2013, 11:20 PM
If the data is coming in as a string and you don't have a type on the field in the model then it will think it's just a string. Setting type to 'int' will convert it to an integer allowing the sorting to be numeric.

What do you mean by 'type'? In my column config object I can set xtype, attrType. I have tried setting both to 'numbercolumn' and 'float'/'int', respectively, but no success. My other options look like this:

flex: 0.75,
align: 'center',
filterable: true,
sortable: true,
filter: {
type: 'numeric',
active: true,
},
xtype: 'numbercolumn',
attrType: 'int',


BTW, filtering works numerically! Please help.

amaunz
12 Mar 2013, 4:01 AM
Ok, I have solved it. Setting attrType to decimal in Netzke does the trick. Thank you!