Results 1 to 2 of 2

Thread: Enhancement: Ext.field.Select setting a value if it uses remote Store

  1. #1
    Sencha User nak1's Avatar
    Join Date
    Jan 2008
    Posts
    303
    Answers
    2
    Vote Rating
    1
      0  

    Default Enhancement: Ext.field.Select setting a value if it uses remote Store

    I've ran into this a few time where I use an Ext.field.Select and I call setValue() prior to it's store completing it's remote load of data. Thus the value isn't displayed in the selection.

    I've written an override to the Ext.field.Select.applyValue method to account for this, and I was wondering if this is something you would consider adding to your framework? I'm not certain how many other users run into this issue but it seems like it might be a common enough issue to warrant a solution

    Code:
    applyValue: function(value) {
    		        var record = value,
    		            index, store;
    		
    		        //we call this so that the options configruation gets intiailized, so that a store exists, and we can
    		        //find the correct value
    		        this.getOptions();
    		
    		        store = this.getStore();
    		        if ((value != undefined && !value.isModel) && store) {
    					//Override to set the value of the store if it's still loading
    					if(store.isLoaded()==false && store.isLoading() && value!=null){
    						//Set a single event to set the value of the store once it's loaded
    						store.on('load',function(s,r){
    							this.setValue(value);
    						},this,{single:true})
    					}
    					else{
    						index = store.find(this.getValueField(), value, null, null, null, true);
    		
    			            if (index == -1) {
    			                index = store.find(this.getDisplayField(), value, null, null, null, true);
    			            }
    			
    			            record = store.getAt(index);
    					}
    					
    		            
    		        }
    		
    		        return record;
    		    }
    		})
    No longer a Newbie

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    Thank you for your contribution.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

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