Results 1 to 6 of 6

Thread: Combination Grid with PagingLoader and GridStateHandler doesn't work as expected

    Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Ext GWT Premium Member gdlm's Avatar
    Join Date
    Jan 2012
    Location
    Belgium
    Posts
    220

    Default Combination Grid with PagingLoader and GridStateHandler doesn't work as expected

    Hi,

    We had a grid - filled with items using a PagingLoader - that worked as expected.

    Additionally, we wanted the grid's sorting column + order to be "remembered".
    After some searching around, we found out that could be done by using a GridStateHandler.

    In the constructor of our IssueGrid class (extending Grid) we added this extra code (inside the if (stateId != null) condition):

    Code:
    public class IssueGrid<T extends IssueDTO> extends Grid<T> {
    
        private GridStateHandler<T> stateHandler;
    
        public IssueGrid(String stateId, ListStore<T> listStore, CheckBoxSelectionModel<T> selectionModel, ColumnModel<T> columnModel) {
            super(listStore, columnModel);
            setColumnReordering(true);
            if (stateId != null){
                if (Storage.isLocalStorageSupported()){
                    setStateful(true);
                    setStateId(stateId);
    
                    stateHandler = new GridStateHandler<T>(this, stateId);
                    stateHandler.loadState();
                }
            }
        ....
        }
    
        @Override
        public void onDetach(){
            if (stateHandler!=null){
                stateHandler.saveState();
            }
            super.onDetach();
        }
    Initially, the column the items are sorted on, is indeed the one they were sorted on when leaving the application. Good.
    But... we experience the following:

    * Initially the item in the grid are sorted according to column X
    * We click on the header of column Y.
    * The database items returned indeed correspond with the clicked column Y (ie. it are the first/last 'pageSize' items ordered by the field shown in the clicked column Y)
    But... those items are shown in the grid ordered by column X (although the sort icon is on the clicked column Y)
    * Every click on another column header: same story; the items keep being ordered according to their values of column X.

    Is the couple [PagingLoader - GridStateHandler] an impossible combination?
    If not, how do I make them work together in harmony?

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

    Default

    It is hard to say without having a testcase. Would it be possible to provide a fully working testcase implementing EntryPoint?

    Are you saying that as soon as you add the state handling the Grid sorting does not work anymore?

  3. #3
    Ext GWT Premium Member gdlm's Avatar
    Join Date
    Jan 2012
    Location
    Belgium
    Posts
    220

    Default

    Are you saying that as soon as you add the state handling the Grid sorting does not work anymore?
    That's indeed the case.
    Although the correct - according to the clicked column - items are shown in the grid, they are NOT sorted correctly.
    They are not sorted according to the clicked column but according to the column that was saved in the GridState the previous time.

    Would it be possible to provide a fully working testcase implementing EntryPoint?
    I'll see if I can come up with something. Maybe by adding statehandling to the paging Grid example.

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

    Default

    I will move this thread to the bugs forum and push it to JIRA. Thanks for reporting it.

  5. #5
    Ext GWT Premium Member
    Join Date
    Jul 2010
    Posts
    23

    Default

    We have just come up against this issue, is there an advised workaround for it ? Maybe pushing the sort order into the state after column headers are clicked?

  6. #6
    Sencha User
    Join Date
    Jun 2013
    Posts
    7

    Default

    Hi, i dont know if this issue is fixed but i experimented quite the same issue.In my case the data are sorted on the server side.
    The issue with the GridStateHandler is that the sort info loaded from the state is always applied to the ListStore even if the grid is remote sorted which causes bad behaviour.
    I fixed it with this code in my own the GridStateHandler (function applyState()):


    Code:
    if (state.getSortField() != null) {
                    ValueProvider<? super M, Comparable> vp =
                            (ValueProvider) getObject().getColumnModel().findColumnConfig(state.getSortField())
                                    .getValueProvider();
    
      if (vp != null) {
       /*
        * FIX BUG GXT 3.0.1
        */
         if (getObject().getLoader() == null || !getObject().getLoader().isRemoteSort()) {
             // local store sorting
             getObject().getStore().clearSortInfo();
             getObject().getStore().addSortInfo(new StoreSortInfo<M>(vp, state.getSortDir()));
         } else {
             // remote sorting
             SortInfoBean bean = new SortInfoBean(vp, state.getSortDir());
             getObject().getLoader().clearSortInfo();
             getObject().getLoader().addSortInfo(bean);
          }
        }
    }
    Hope it will help

Posting Permissions

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