Hybrid View
-
17 Mar 2009 6:26 AM #1
GXT 1.2.3 : Sort Dates in Grid
GXT 1.2.3 : Sort Dates in Grid
In a Grid, I have a column "Date", and when I want to sort this column, the dates sort correctly in host mode but do not sort correctly with Firefox or IE.
It was OK with version 1.1.1 but not with 1.2.3.
-
17 Mar 2009 6:36 AM #2
-
17 Mar 2009 6:59 AM #3
work fine in host mode, but not in firefox or IE.Code:public class NewTabItem extends TabItem { private GroupingStore<BaseModel> gridStore; public NewTabItem (List<BaseModel> dates) { super(); List<ColumnConfig> columns = new ArrayList<ColumnConfig>(); ColumnConfig date = new ColumnConfig("Date", "Released", 80); date.setDateTimeFormat(DateTimeFormat.getFormat("MMMM dd, yyyy")); columns.add(date); final ColumnModel cm = new ColumnModel(columns); final GroupingView view = new GroupingView(); view.setForceFit(true); view.setGroupRenderer(new GridGroupRenderer() { public String render(GroupColumnData data) { String l = data.models.size() == 1 ? "Item" : "Items"; return data.group + " (" + data.models.size() + " " + l + ")"; } }); gridStore = new GroupingStore<BaseModel>(); gridStore.add(dates); Grid grid = new Grid<BaseModel>(gridStore, cm); grid.setLoadMask(true); grid.setBorders(true); grid.setView(view); setLayout(new FitLayout()); setStyleAttribute("margin", "8px 0 0 0"); add(grid); } }
see image : (Dates are sorted in DESC...)

-
17 Mar 2009 7:07 AM #4
-
17 Mar 2009 7:14 AM #5
Sorry, it's DateTimeFormat.getFormat("MMMM dd, yyyy"); in my code
but it's not the problem. The result is the same.
-
20 Mar 2009 3:50 AM #6
Same problem for me.
Have a column configuration with DateTimeFormat specified.
Grid sorts it as a string rather than a date
-
23 Mar 2009 5:19 AM #7
-
23 Mar 2009 5:25 AM #8
GXT 1.1.1 :
- Host mode : OK
- IE : OK
- Firefox : OK
GXT 1.2.3 :
- Host mode : OK
- IE : ERROR
- Firefox : ERROR
With the same code for 1.1.1 and 1.2.3

WHY ?
-
3 Sep 2009 2:09 AM #9
Same in 2.0.1
Same in 2.0.1
I am having the same issue in GXT 2.0.1. Did you ever get this resolved?
-
3 Sep 2009 4:56 AM #10
Figured It Out
Figured It Out
Looks like a GWT bug
http://code.google.com/p/google-web-...00&q=compareto
Basic issue is that the compareTo method in java.sql.Timestamp is broken. If you are returning Timestamp objects from the backend you will run into this issue.
We wound up creating our own local copy of the emulated Timestamp class and changing the compareTo method to
Code:public int compareTo(Timestamp o) { /* int delta = (int) (getTime() - o.getTime()); return delta == 0 ? getNanos() - o.getNanos() : delta; */ int i = super.compareTo(o); if (i == 0) { if (getNanos() > o.getNanos()) { return 1; } else if (getNanos() < o.getNanos()) { return -1; } } return i; }


Reply With Quote