1. #1
    Ext User
    Join Date
    Jun 2007
    Posts
    9
    Vote Rating
    0
    krypt0se is on a distinguished road

      0  

    Question Disabling grid when reloading datasource

    Disabling grid when reloading datasource


    When someone clicks the next or previous or when the grid initially loads, the grid shows a load mask and the grid is disabled. But when i do a datasource.reload() in the loadexception event the loadMask appears for a few seconds and disappears even before the data is returned. Is there a way to keep the load mask active till the data is refreshed when doing a reload too?

    i have the listeners for the Store setup as something like this

    Code:
    listeners: {
            	beforeload: function(store, options){
            		store.removeAll();
    	        	if(retry == 0) {	        	
    	        		grid.loadMask.msg = "Loading...";
    	        	} else if(retry <= totalRetries) {
    	        		grid.loadMask.msg = "Retrying (" + (retry+1)+ ")...";
    	        	} else {
    	        		retry = 0;
    	        		grid.loadMask.msg = "Loading...";
    	        	}
            	},
            	load: function() {        		
            		retry = 0;       		
            	},
            	loadexception: function(proxy, store, response, e) {
            		retry++;
          			if(retry <= totalRetries){				        		
    	        		ds.reload();
    	        		grid.reconfigure(grid.getDataSource(), grid.getColumnModel());
            		}
    		}
    }

  2. #2
    Sencha Premium Member MaximGB's Avatar
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    508
    Vote Rating
    5
    MaximGB is on a distinguished road

      0  

    Default


    Code:
    grid.reconfigure(grid.getDataSource(), grid.getColumnModel());
    What is it for?
    Use the force - read the source.

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

      0  

    Default


    that was just something i tried to see if it would bring up the load mask, i forgot to remove it

  4. #4
    Sencha Premium Member MaximGB's Avatar
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    508
    Vote Rating
    5
    MaximGB is on a distinguished road

      0  

    Default


    Try to defer the reload call like
    Code:
    ds.reload.defer(100, ds);
    Use the force - read the source.

  5. #5
    Ext User
    Join Date
    Jun 2007
    Posts
    9
    Vote Rating
    0
    krypt0se is on a distinguished road

      0  

    Thumbs up


    Thanks a ton!! that worked! I still don't understand what ds.reload.defer(100, ds) did though, since if reload was deferred how did the load mask appear even without calling the reload?

  6. #6
    Sencha Premium Member MaximGB's Avatar
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    508
    Vote Rating
    5
    MaximGB is on a distinguished road

      0  

    Default


    Code:
    ds.reload.defer(100, ds);
    Means "please Ext wait 100 ms and call the ds.reload method in context of ds object".
    So the sequence is:
    1. call before load listeners
    2. show load mask
    3. do the Ajax request
    4. exception occured
    5. call load exception listeners -> defer reload
    6. hide load mask
    7. defered reload
    8. goto 1
    Use the force - read the source.

  7. #7
    Ext User
    Join Date
    Jun 2007
    Posts
    9
    Vote Rating
    0
    krypt0se is on a distinguished road

      0  

    Default


    got it! thanks a lot!

Thread Participants: 1