Results 1 to 4 of 4

Thread: Ext 6.5.3 BUG - Stateful grid bound to sorted store fails to apply initial state

    You found a bug! We've classified it as EXTJS-26854 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha Premium Member
    Join Date
    Aug 2008
    Posts
    23

    Default Ext 6.5.3 BUG - Stateful grid bound to sorted store fails to apply initial state

    This bug has also been reported on the support site, I am posting it here for other users who may run into it.

    Stateful grids bound to stores with any sorters configured will fail in their applyState method with a null reference to viewModel. Specifically the me.getViewModel().bind() call in the below code snippet from Ext.panel.Table.applyState:

    Code:
    // New storeState which encapsulates groupers, sorters and filters.
    else if (storeState) {
        // if we are binding a store, we should schedule the applyState method
        // to run as soon as the store is available
        bind = this.getBind();
        boundStore = bind && bind.store;
        if (boundStore && boundStore.isBinding) {
            // this will notify the viewModel once the store binding process is complete
            // and will run applyState for the newly bound store
            me.getViewModel().bind('{' + boundStore.stub.path + '}', function(store) {
                store.applyState(storeState);
            }, this, {
                single: true
            });
        } else {
            store.applyState(storeState);
        }
    }
    I can only assume this is because the applyState method is firing before the viewModel is actually configured for the view. The following override will get around this bug if you do not care about sorters or filters being stateful:

    Code:
    Ext.define('ExtOverride.panel.Table', {
        override: 'Ext.panel.Table',
        // disable stateful sorters and filters
        applyState: function(state) {
            state.sort = false;
            state.storeState = false;
            this.callParent(arguments);
        }
    });
    And finally here is the fiddle that demonstrates the issue. On first load it will work. Rearrange a column then run the fiddle again. It will fail.

    https://fiddle.sencha.com/#fiddle/2ds9

  2. #2
    Sencha Premium User
    Join Date
    Aug 2016
    Posts
    3

    Default

    I found the same bug a day or so after you posted this. I also found a possible workaround that I have thrown in while I test other things. If you swap out the me.getViewModel() for me.lookupViewModel() it appears to function correctly. I am just not sure if this change has any unintended consequences, but I figured I would share in case anyone wants to mess around with it.

    Here is the updated fiddle with the override that swaps the view model.

    https://fiddle.sencha.com/#fiddle/2dtu&view/editor

  3. #3
    Sencha Premium User
    Join Date
    Apr 2011
    Posts
    126

    Default

    I ran into this after updating to 6.5.3. I finally tracked this down and was about to report it when I found this post. I will try the workaround above.
    Thank you.

  4. #4
    Sencha Premium User
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    getViewModel is absolutely the wrong call to be making there. It assumes the viewmodel is directly attached to the grid.

Similar Threads

  1. [OPEN] Sorted, grouped store/state grid misbehaving
    By incutonez in forum Ext JS 6.x Bugs
    Replies: 1
    Last Post: 31 Oct 2016, 8:20 AM
  2. stateful grid with custom state provider hack
    By herme063 in forum Ext JS 6.x Q&A
    Replies: 1
    Last Post: 23 Sep 2016, 5:26 AM
  3. Replies: 6
    Last Post: 15 Sep 2015, 3:02 AM
  4. Replies: 5
    Last Post: 30 Apr 2014, 1:39 PM
  5. stateful grid state restore without reload
    By NeoVanGoth in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 25 Jun 2009, 7:29 AM

Posting Permissions

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