View Full Version : GXT 1.2.3 : Sort Dates in Grid
91dj85
17 Mar 2009, 6:26 AM
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.
fother
17 Mar 2009, 6:36 AM
for me work fine
look http://www.extjs.com/explorer/#editablegrid
post the code example
91dj85
17 Mar 2009, 6:59 AM
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);
}
}
work fine in host mode, but not in firefox or IE.
see image : (Dates are sorted in DESC...) :-?
http://img27.imageshack.us/img27/950/sortgrid.png
fother
17 Mar 2009, 7:07 AM
look http://extjs.com/deploy/gxtdocs/com/extjs/gxt/ui/client/widget/grid/ColumnConfig.html#setDateTimeFormat%28com.google.gwt.i18n.client.DateTimeFormat%29 test with this
91dj85
17 Mar 2009, 7:14 AM
Sorry, it's DateTimeFormat.getFormat("MMMM dd, yyyy"); in my code
but it's not the problem. The result is the same.
MikeS
20 Mar 2009, 3:50 AM
Same problem for me.
Have a column configuration with DateTimeFormat specified.
Grid sorts it as a string rather than a date
91dj85
23 Mar 2009, 5:19 AM
look http://extjs.com/deploy/gxtdocs/com/...eTimeFormat%29 test with this
it's not the problem
91dj85
23 Mar 2009, 5:25 AM
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 ?
Kroywen
3 Sep 2009, 2:09 AM
I am having the same issue in GXT 2.0.1. Did you ever get this resolved?
Kroywen
3 Sep 2009, 4:56 AM
Looks like a GWT bug
http://code.google.com/p/google-web-toolkit/issues/detail?id=3600&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
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;
}
rlaferla
13 Nov 2009, 1:27 PM
I'm having this problem with GXT 2.0.4 and GWT 1.7.1. How do you apply the patch? I'm also using Date not Timestamp.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.