-
31 May 2010 5:30 AM #1
Sorting Scientific values and Decimals in a Grid column
Sorting Scientific values and Decimals in a Grid column
Hi,
I have grid with a column that has decimal values like (1.6,2.3,0.2) as well as exponential values like (3e-70,4e-80) etc etc. When I try to sort the column then it just sorts the data in lexicographical manner i.e. 2 is put before 3e-70 while sorting in an ascending manner. I tried using a numberRenderer as:
and then using this renderer in my column config as:Code:NumberFormat format = NumberFormat.getScientificFormat(); final NumberCellRenderer<Grid<BeanModel>> cellRenderer = new NumberCellRenderer<Grid<BeanModel>>(format); GridCellRenderer<BeanModel> gridNumber = new GridCellRenderer<BeanModel>() { public String render(BeanModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<BeanModel> store, Grid<BeanModel> grid) { return cellRenderer.render(null, property, model.get(property)); } };
But it seems not to be working. Any ideas?Code:column = new ColumnConfig("minEVal","Min E-Val",75); column.setRenderer(gridNumber); columns.add(column);
- ParitParit Bansal
Masters Student (Computational Biology and Bioinformatics)
ETH Zurich
Switzerland
-
31 May 2010 5:32 AM #2
what type are your values? Do you have them as a string?
-
31 May 2010 6:24 AM #3
yes of course.. got it fixed
thankx..
- ParitParit Bansal
Masters Student (Computational Biology and Bioinformatics)
ETH Zurich
Switzerland
-
31 May 2010 6:25 AM #4
So please post your solution so others can use it too
-
31 May 2010 6:31 AM #5
As it turned out.. the fields of the model class that were rendered by the grid were strings instead of being double thats why when a sort is called on a column then the items in it were sorted lexicographical and not as numbers. So, I just changed the relevant fields from String to double. problem solved
Parit Bansal
Masters Student (Computational Biology and Bioinformatics)
ETH Zurich
Switzerland
Similar Threads
-
Grid: Scientific notation in column
By randomuser01 in forum Ext 2.x: Help & DiscussionReplies: 5Last Post: 23 Dec 2008, 10:36 PM -
Grid fails with scientific notation
By drujensen in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 12 Jun 2008, 4:39 PM -
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