Results 1 to 5 of 5

Thread: [FIXED] [1.1.3]Grid only fires SortChange event once

  1. #1

    Default [FIXED] [1.1.3]Grid only fires SortChange event once

    I am expecting that my listener for the SortChange event on a Grid will be called each time the sort order is modified in the UI. My event handler looks like:

    grid.addListener( Events.SortChange, new Listener<GridEvent>() {
    public void handleEvent( GridEvent e ) {
    sortDir = e.sortInfo.getSortDir();
    sortField = e.sortInfo.getSortField();
    GWT.log( "SortChange event on grid "+sortField+" "+ sortDir.toString(), null );
    }
    });


    I've set a break point in this listener, and also in GridView's updateHeaderSortState() method.

    Each time I click in a column header to change the sort column or the sort order, GridView's updateHeaderSortState() gets called. The first time that I click on a column header to change the sort state, the thread makes it into this block of code in updateHeaderSortState():

    if (this.sortState == null || (!this.sortState.getSortField().equals(state.getSortField()))
    || this.sortState.getSortDir() != state.getSortDir()) {
    GridEvent e = new GridEvent(grid);
    e.sortInfo = state;
    grid.fireEvent(Events.SortChange, e);
    }


    and successfully fires the SortChange event. However usually after the first time that I click on a column header to change the sort state, it never makes into this block of code again (occasionally it works 3 or 4 times in a row, but usually it fails). The rest of the calls fail to make it into this if-block because this.sortState has the same value as state. The result of course is that my event handler does not get called.

    The sorting in the columns functions properly, but my application needs to be informed when the sort state changes.


  2. #2
    Sencha User darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242

    Default

    Thanks for the detailed post. Fixed in SVN.

  3. #3

    Default

    Looks like I'm having this problem too...

    The remote sort that is being triggered when sorting via the grid headers doesn't look like it modifies our data stores base params, so when I use the paging toolbar it loads the next page without the sort changes I specified. It instead loads using the data store's out of date sort info from the base params.

    I hoped to work around this using the GridPanel's sortChange event. I'd be able to apply the new sort info to the base params on each remote sort so the data store would always have the updated info, but unfortuantely this only looks like it is firing once per grid.

    Looking at GridView's updateHeaderSortState function it appears that our data store's sortInfo is never being updated. The event fires the first time because this.sortState is undefined. After that I'd think the second condition here would cause it fire the additional times. Looks like our sortState and state objects are not being updated.

    Code:
     if(!this.sortState || (this.sortState.field != state.field || this.sortState.direction != state.direction)){
                this.grid.fireEvent('sortchange', this.grid, state);
            }
    We've been using ext 2.2. I swapped in 2.2.1 to see if this corrected the issue and it did not. Could it be related to the way we've declared our store/grid? The code for those two is very generic but I can post it if that would be helpful.

    Thanks!

  4. #4
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976

    Default

    This bugreport was fore Ext GWT and not for Ext JS. I suggest to post in the Ext JS forums.

  5. #5

    Default

    touche...sorry bout that one

Posting Permissions

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