Results 1 to 8 of 8

Thread: Sorting Order gets lost when you use groupBy

  1. #1
    Sencha User
    Join Date
    Apr 2010
    Posts
    36
    Vote Rating
    0
      0  

    Default Sorting Order gets lost when you use groupBy

    Hi,

    Detailed description of the problem
    using a Grid with Paging and Grouping works fine. But everytime you select another column for grouping (by passing the name of the column to groupBy(String)) the information about the column to sort by and the sorting order gets lost. The bug appears if you use setRemoteGroup(true) and setGroupOnSort(false).

    GXT version
    2.1.1

    Host mode / web mode / both
    only tried web mode

    Browser and version
    FireFox 3.6, Internet Explorer 8

    Operating System
    Windows XP

    Sample code
    The grouping store is set up ass following:
    Code:
    final GroupingStore<BaseModelData> groupingStore = new GroupingStore<BaseModelData>(                   loader);
    
    // set some default attributes
    groupingStore.setGroupOnSort(false);
    groupingStore.setRemoteGroup(true);
    
    // set the passed attributes
    groupingStore.groupBy(gridBean.getGroupByField());
    Whenever load is fired the configuration is checked, whereby the last configuration is stored in config (the sorting on server side works fine and the data is sorted by group ASC and than by all passed fields (depending on the Sorting Order))...
    Code:
    if (loadConfig instanceof GroupingLoadConfig) {
      final GroupingLoadConfig groupingLoadConfig = (GroupingLoadConfig) loadConfig;
    
      config.set("groupBy", groupingLoadConfig.getGroupBy());
    } else if (loadConfig instanceof PagingLoadConfig) {
      final PagingLoadConfig pagingLoadConfig = (PagingLoadConfig) loadConfig;
    
      config.set("limit", pagingLoadConfig.getLimit());
      config.set("offset", pagingLoadConfig.getOffset());
      config.setSortDir(pagingLoadConfig.getSortDir());
      config.setSortField(pagingLoadConfig.getSortField());
    } else {
      final ListLoadConfig listLoadConfig = (ListLoadConfig) loadConfig;
    
      config.setSortDir(listLoadConfig.getSortDir());
      config.setSortField(listLoadConfig.getSortField());
    }
             
    asyncService.getPagedData(configName, gridBean.getName(),
       gridBean.getParameters(), config, callback);

  2. #2
    Sencha User
    Join Date
    Apr 2010
    Posts
    36
    Vote Rating
    0
      0  

    Default I think it is a bug...

    ... but maybe I'm wrong...

    So the refreshing of the ColumnHeader is wrong

    Code:
    if (container instanceof Grid) {
          Grid grid = (Grid)container;
          SortInfo sortInfo = grid.getStore().getSortState();
          if (sortInfo != null && sortInfo.getSortField() != null) {
            ColumnModel cm = grid.getColumnModel();
            ColumnConfig column = cm.getColumnById(sortInfo.getSortField());
            updateSortIcon(cm.indexOf(column), sortInfo.getSortDir());
          }
    }
    Is the code used (com.extjs.gxt.ui.client.widget.gridColumnHeader#refresh)... and cm.getColumnById(sortInfo.getSortField()); will always return null cause as far as I remember the SortField is defined by the data index and not by the id... well it will not return null if the dataIndex == id... is that correct? Is that really a bug? Would be glad if someone could tell me if it is or not (cause someone moved it into this part of the forum)... But I think this should not only occure when there is a paging connected to it... I guess it is a general bug with HeaderColumns and refreshing (whoever triggers the refresh).

    I'm not sure if the sortField is the id or the dataindex, but it is used in the source as both (see above it is used as id) and in com.extjs.gxt.ui.client.widget.grid.GridView#updateHeaderSortState there is
    Code:
    int sortColumn = cm.findColumnIndex(state.getSortField());
    So to fix this... You can just use the code of the updateHeaderSortState in the refresh... but again if I think about it... the refresh could select the wrong column than... cause there could be two columns (with different ids) but the same dataindex...

    Thanks

  3. #3
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    It got moved because you ignored the bugforum guidelnies once again completly. Posts like this get moved to the help forum.

    The code willbe changed for GXT 2.2. GXT 2.2 wont have the problem

  4. #4
    Sencha User
    Join Date
    Apr 2010
    Posts
    36
    Vote Rating
    0
      0  

    Default

    So I just tested it with

    Code:
    if (container instanceof Grid) {
          Grid grid = (Grid)container;
          SortInfo sortInfo = grid.getStore().getSortState();
          if (sortInfo != null && sortInfo.getSortField() != null) {
            ColumnModel cm = grid.getColumnModel();
            updateSortIcon(cm.findColumnIndex(sortInfo.getSortField()), sortInfo.getSortDir());
          }
    }
    and it works this way... I'm still wondering if it wouldn't be better to also add the "SortId" instead of the "SortDataIndex == SortField" cause as mentioned, if you refresh now with the bug fix and there are two columns using the same data index (but different id, e.g. date field with dd.MM.yyyy and a second field with HH:mm) the sort-arrow will move from the second to the first column...

    Or maybe all this is already fixed and I didn't find the right post in the forum (I'm really bad with finding the right search words)...

  5. #5
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    The second issue cannot be fixed at the moment without making big changes. I know about it and will look for GXT3 into it.

  6. #6
    Sencha User
    Join Date
    Apr 2010
    Posts
    36
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by sven View Post
    It got moved because you ignored the bugforum guidelnies once again completly. Posts like this get moved to the help forum.
    I corrected the post (to its current form) after you told me... so I guess you should look before moving or give people at least some time to fix their posts if you tell them that the format is incorrect... or is the current form incorrect again?!

    Well the sample is not there... but I guess I don't always have the time to create samples... but I'll try to post better bug reports next time ...

    By the way is the autofill (http://www.extjs.com/forum/showthrea...ot-last-column) problem solved also so easily? Or is it more work than "just changing one line"? Cause if it is I would appreciate to know the line of code...

  7. #7
    Sencha User
    Join Date
    Apr 2010
    Posts
    36
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by sven View Post
    The second issue cannot be fixed at the moment without making big changes. I know about it and will look for GXT3 into it.
    Thanks for the quick note! I can live with that, right now

  8. #8
    Sencha Premium User
    Join Date
    Sep 2009
    Posts
    311
    Vote Rating
    1
      0  

    Default

    for this example http://www.sencha.com/examples/explo...ml#localpaging how I can create a local paging using groupview?

    thanks

Similar Threads

  1. groupBy and sort in GridPanel
    By yaminih in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 1 Dec 2009, 9:21 PM
  2. Groupby Text with CheckboxSelectionModel
    By joutsource in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 28 Jul 2009, 2:57 PM
  3. Grid paging, grouping sorting and filtering = lost unsaved changes
    By froamer in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 9 Jan 2008, 1:43 AM
  4. gridPanel drag 'n drop for sorting order
    By Graaf in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 15 Dec 2007, 3:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •