Hybrid View

  1. #1
    Ext User
    Join Date
    Mar 2009
    Posts
    16
    Vote Rating
    0
    91dj85 is on a distinguished road

      0  

    Default 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.

  2. #2
    Ext User fother's Avatar
    Join Date
    Sep 2007
    Location
    Brazil
    Posts
    744
    Vote Rating
    -1
    fother is an unknown quantity at this point

      0  

    Default


    for me work fine

    look http://www.extjs.com/explorer/#editablegrid

    post the code example

  3. #3
    Ext User
    Join Date
    Mar 2009
    Posts
    16
    Vote Rating
    0
    91dj85 is on a distinguished road

      0  

    Default


    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);
        }
    
    }
    work fine in host mode, but not in firefox or IE.
    see image : (Dates are sorted in DESC...)

  4. #4
    Ext User fother's Avatar
    Join Date
    Sep 2007
    Location
    Brazil
    Posts
    744
    Vote Rating
    -1
    fother is an unknown quantity at this point

      0  

  5. #5
    Ext User
    Join Date
    Mar 2009
    Posts
    16
    Vote Rating
    0
    91dj85 is on a distinguished road

      0  

    Default


    Sorry, it's DateTimeFormat.getFormat("MMMM dd, yyyy"); in my code
    but it's not the problem. The result is the same.

  6. #6
    Ext User
    Join Date
    Mar 2009
    Posts
    1
    Vote Rating
    0
    MikeS is on a distinguished road

      0  

    Default


    Same problem for me.
    Have a column configuration with DateTimeFormat specified.
    Grid sorts it as a string rather than a date

  7. #7
    Ext User
    Join Date
    Mar 2009
    Posts
    16
    Vote Rating
    0
    91dj85 is on a distinguished road

      0  

    Default


    it's not the problem

  8. #8
    Ext User
    Join Date
    Mar 2009
    Posts
    16
    Vote Rating
    0
    91dj85 is on a distinguished road

      0  

    Default


    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 ?

  9. #9
    Ext User
    Join Date
    Sep 2009
    Posts
    2
    Vote Rating
    0
    Kroywen is on a distinguished road

      0  

    Default 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?

  10. #10
    Ext User
    Join Date
    Sep 2009
    Posts
    2
    Vote Rating
    0
    Kroywen is on a distinguished road

      0  

    Default 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;
      }