1. #1
    Ext User
    Join Date
    Apr 2009
    Posts
    19
    Vote Rating
    0
    Mag_42 is on a distinguished road

      0  

    Question Remote Grouping and Stateful grid causing store to load too early

    Remote Grouping and Stateful grid causing store to load too early


    I've noticed this problem I've been having where something in a state cookie is causing my stores to load automatically on page load instead of on demand when i want them to.

    After a bit of elimination I've tracked it down to something to do with remote grouping.

    In order to replicate this you can just take the Hybrid Summary example and do the following to totals-hybrid.js

    Add in a State Provider at the top...
    Code:
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
    Add the following to the grid panel
    Code:
          
    stateful: true,
    stateId: 'statetest',
    And set the store to Remote Grouping
    Code:
     remoteGroup: true,
    Enable the grouping Menu in the GroupingView
    Code:
     enableGroupingMenu:true,
    Finally comment out the store load at the end of the page
    Code:
    grid.store.load();
    Now if you load the page you'll get a blank grid as the store will not load. However if you group by any column the store will load as it has to send a new request due to remote grouping.

    After this point any time you refresh the page it always loads the store even though the storeload() is commented out at the end.

    This doesn't seem to happen with remote sorting or remote filtering and I'd love to know how to stop it from happening as I cant seem to find out how myself.

    This doesn't appear to be a result of the Hybrid summary plugin. If you remove all reference to that you get the same behaviour.

    If anyone has any suggestions I'd really appreciate it.

  2. #2
    Ext User
    Join Date
    Apr 2009
    Posts
    19
    Vote Rating
    0
    Mag_42 is on a distinguished road

      0  

    Default


    Nobody has an idea?

    Or is this a bug?

    I didn't want to post in the Bugs forum untill i had checked it here first.

  3. #3
    Ext User
    Join Date
    Apr 2009
    Posts
    19
    Vote Rating
    0
    Mag_42 is on a distinguished road

      0  

    Default


    Ok well with no suggestions I guess im going to have to treat it as a bug as it is unexpected behaviour.

  4. #4
    Ext User
    Join Date
    Aug 2009
    Posts
    588
    Vote Rating
    1
    Mike Robinson is on a distinguished road

      0  

    Default


    Before you conclude that "it is a bug" (and that "no one is paying attention to you"), you should methodically check for possibilities.

    For example, are you certain that the autoLoad property of the Store is expressly set to false?

    Try simplifying the surrounding programming to the barest set of (test case...) programming that reproduces the erroneous behavior. Then, set a breakpoint (e.g. in FireBug) straight onto the load() method, as well as to any methods that it immediately calls. This will tell you where the call is coming from, and why.

    There are many "possible contributing factors" that you allude-to here in your original post, only one of which is "it's a bug." (Of course, that is a legitimate possibility.) Since you are seeing it, you need to be the one who takes the first stab at isolating it, and turning it into something that is both "reproducible" and "actionable."

  5. #5
    Ext User
    Join Date
    Apr 2009
    Posts
    19
    Vote Rating
    0
    Mag_42 is on a distinguished road

      0  

    Default


    Thanks for the suggestions Mike though I thought I had made it reproduceable enough by taking a problem i was experienceing in my own code and reproducing it through some minor modifications to an EXTjs example.

    I didn't mean to imply that no one was paying attention to me (i can see people have viewed it) only that the lack of response indicated it was perhaps not something people have encountered before (and not a RTFM kind of thing though i suppose those would solicit no response either) and as such was more likely to be a weird bug or unexpected behaviour than something people know about and expect that I am unaware of.

    I'll go through and double check those things you mentioned.

  6. #6
    Ext User
    Join Date
    Apr 2009
    Posts
    19
    Vote Rating
    0
    Mag_42 is on a distinguished road

      0  

    Default


    ok autoLoad: false does not change anything. The store still loads automatically with remote grouping turned on.

    (which is good as i would look rather silly if that would fix it though i would prefer it to be fixed really)

    I'll delve into breakpoints in remote group to see whats calling it.

  7. #7
    Ext User
    Join Date
    Apr 2009
    Posts
    19
    Vote Rating
    0
    Mag_42 is on a distinguished road

      0  

    Default


    Ok so applyState in Ext.grid.Gridpanel has the following code (line 64472 in ext-all-debug ext 3.1.1)

    Code:
     
                s = state.group;
                if(store.groupBy){
                    if(s){
                        store.groupBy(s);
                    }else{
                        store.clearGrouping();
                    }
                }
    If remoteGrouping is turned on both store.groupBy and store.clearGrouping will call store.reload()... so just having a state cookie to apply and remoteGroup: true turned on in the store will cause the store to load as soon as the state is applied... which i wouldn't think is desirable. I would think it would be best just to apply the appropriate params to the store so they can be applied when ever the store needs to be loaded.

    Ext.data.GroupingStore - groupBy() line 37092 in ext-all-debug
    Code:
    groupBy : function(field, forceRegroup, direction){
           direction = direction ? (String(direction).toUpperCase() == 'DESC' ? 'DESC' : 'ASC') : this.groupDir;
            if(this.groupField == field && this.groupDir == direction && !forceRegroup){
                return; // already grouped by this field
            }
            this.groupField = field;
            this.groupDir = direction;
            this.applyGroupField();
            if(this.groupOnSort){
                this.sort(field, direction);
                return;
            }
            if(this.remoteGroup){
                this.reload();
            }else{
                var si = this.sortInfo || {};
                if(forceRegroup || si.field != field || si.direction != direction){
                    this.applySort();
                }else{
                    this.sortData(field, direction);
                }
                this.fireEvent('datachanged', this);
            }
        },
    Ext.data.groupingStore - ClearGrouping() - line 37065 of ext-all-debug
    Code:
    clearGrouping : function(){
            this.groupField = false;
    
            if(this.remoteGroup){
                if(this.baseParams){
                    delete this.baseParams.groupBy;
                    delete this.baseParams.groupDir;
                }
                var lo = this.lastOptions;
                if(lo && lo.params){
                    delete lo.params.groupBy;
                    delete lo.params.groupDir;
                }
    
                this.reload();
            }else{
                this.applySort();
                this.fireEvent('datachanged', this);
            }
        }
    I get why the individual groupBy and clearGrouping functions call store.reload() since that's what you'd want to happen as soon as you remove grouping or group by a new field. But maybe applyState should not be using those functions do do what it needs to do.

  8. #8
    Ext User
    Join Date
    Apr 2009
    Posts
    19
    Vote Rating
    0
    Mag_42 is on a distinguished road

      0  

    Default


    ... or maybe groupBy and clearGrouping should have the ability not to reload the store ...

  9. #9
    Ext JS Premium Member
    Join Date
    Oct 2009
    Location
    Melrose, MA
    Posts
    47
    Vote Rating
    3
    hjones is on a distinguished road

      0  

    Default


    Yes, Mag_42, I believe you are right. The fact that the GridPanel:applyState sets any persisted sort details via the setDefaultSort method rather than applying it immediately compared to the grouping's immediate application indicates an inconsistency at the very least.

    When autoLoad is set to false this is going to result in problems.

    I'm seeing the same problem with our application - specifically in FireFox the whole thing turns very nasty with recursive loading of the page - because the groupBy is being called and the remote call made with an empty Store:baseParams struct.

    I'm working through two possible solutions:
    a. Default enough params in the Store:baseParams so that the state-driven call to groupBy succeeds...or
    b. Extend/Subclass the GroupingStore and GridPanel to provide a similar deferred / default groupBy and clearGrouping behavior.

    Let me know if you came up with a working solution please?

  10. #10
    Ext User
    Join Date
    Apr 2009
    Posts
    19
    Vote Rating
    0
    Mag_42 is on a distinguished road

      0  

    Default


    Ok i did fix this... through a series of rather ugly overrides...

    First override the functions in Ext.data.GroupingStore... to include an option not to reload

    Code:
    Ext.override(Ext.data.GroupingStore, {
      groupBy : function(field, forceRegroup, direction, noreload){
      ...
      ...
      ...
       if(this.remoteGroup && !noreload){
                this.reload();
            }else{
       ...
       ...
    },
    clearGrouping : function(noreload){
       ...
       ...
       ...
            if (!noreload)
                   this.reload();
       ...
       ...
       ...
       }
    });
    
    Then override applyState in gridPanel... to tell it not to reload...


    Code:
    Ext.override (Ext.grid.GridPanel, {
      applyState : function(state){
       ...
       ...
       ...
                if(store.groupBy){
                    if(s){
                        store.groupBy(s,null,null,true);
                    }else{
                        store.clearGrouping(true);
                    }
                }
       ...
       ...
       ...
       }
    })
    From recollection I made this really fast and looking at it now it could be a lot better/saner but it worked.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar