1. #1
    Ext User
    Join Date
    Oct 2007
    Posts
    5
    Vote Rating
    0
    jackbquick is on a distinguished road

      0  

    Default Grid reload problem

    Grid reload problem


    I'm having the problem that when the grid is reloaded in the else clause at the bottom and an error occurs (timeout, lost connection) the loadexception event is never received by the eventlistener. It seems that this is due to the new proxy being created. I tried to work around it by reregistering the loadexception after setting the new proxy, however it still didn't work. Any suggestions on how to fix or work around this will be greatly appreciated!

    PHP Code:
    SOMECOMPANY.view.ResultsView.prototype.buildWidget = function(searchUrl) {

        
    // If this is our first time creating the widget...
        
    if (this.dataStore == null) {
            var 
    dataStore = new Ext.data.Store({
                
    proxy: new Ext.data.HttpProxy({urlsearchUrl}),
        
                
    reader: new Ext.data.XmlReader(
                    
    this.xmlReaderConfig.meta
                    
    this.xmlReaderConfig.recordType
                
    )
            });
            
            var 
    grid = new Ext.grid.Grid(this.gridHtmlId
                {
                    
    dsdataStore
                    
    cmthis.colModel
                
    }
            );
            
            
    this.grid grid;        
            
    grid.render();
            
            
    // set up event handlers
            // ----------------------------------
            // listen for when the data is loaded
            
    grid.getDataSource().on("load"this.onLoadthis);
            
            
    // listen for errors related to loading the data  
            
    grid.getDataSource().on("loadException", function(dataProxydataObjectarge) {
        
    alert("Search failed.  Please check your network connection.")}, this);
            
            
    dataStore.load();
        
            
    this.dataStore dataStore;
                
        } 
        else {   
    // If the widget already exists, just reload the data
            
    this.dataStore.proxy = new Ext.data.HttpProxy({urlsearchUrl});
            
    this.dataStore.reload();        
        }


  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    Why are you creating a new proxy to reload? Even if you need to change the parms, you could apply them to the existing proxy object.

  3. #3
    Ext User
    Join Date
    Oct 2007
    Posts
    5
    Vote Rating
    0
    jackbquick is on a distinguished road

      0  

    Default


    I created a new proxy because the url can change based on user selected search criteria. But if I could change the url on the proxy and reuse it that would be great. However I don't know how to change it without creating a new proxy.

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    Any config entry passed to a proxy is considered a public property, so you can change it any time.

  5. #5
    Ext User
    Join Date
    Oct 2007
    Posts
    5
    Vote Rating
    0
    jackbquick is on a distinguished road

      0  

    Default


    I tried changing the proxy url with the following code. However the when the reload is performed it is still using the url from the previous load. Am I missing something or is there another way to reset the property?

    PHP Code:
    this.dataStore.proxy.url searchUrl;
    this.dataStore.reload(); 

  6. #6
    Ext User
    Join Date
    Jun 2007
    Posts
    3
    Vote Rating
    0
    cdudez is on a distinguished road

      0  

    Thumbs up


    instead of

    this.dataStore.proxy.url = searchUrl;
    this.dataStore.reload();

    do

    this.dataStore.proxy = new Ext.data.HttpProxy({url: searchUrl});
    this.dataStore.reload();

    This works!

  7. #7
    Ext User
    Join Date
    Oct 2007
    Posts
    5
    Vote Rating
    0
    jackbquick is on a distinguished road

      0  

    Default


    Quote Originally Posted by cdudez View Post
    instead of

    this.dataStore.proxy.url = searchUrl;
    this.dataStore.reload();

    do

    this.dataStore.proxy = new Ext.data.HttpProxy({url: searchUrl});
    this.dataStore.reload();

    This works!
    This is part of my original problem, as I'm doing it this way in my code above. But when a new proxy is assigned and an error occurs I no longer receive the loadexception events.

  8. #8
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    Creating a new proxy object is not the right way to handle this. My example missed an object - it should be:
    Code:
    store.proxy.conn.url = 'newurl';
    store.reload();
    If in doubt, step thru the code with firebug to see what's going on.

  9. #9
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,505
    Vote Rating
    52
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Are you sure you want to change the url?

    Don't you just want to pass different parameters?

  10. #10
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,505
    Vote Rating
    52
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0