1. #1
    Sencha User nak1's Avatar
    Join Date
    Jan 2008
    Posts
    266
    Answers
    1
    Vote Rating
    0
    nak1 is an unknown quantity at this point

      0  

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

    Unanswered: 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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,207
    Answers
    3517
    Vote Rating
    856
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thank you for your contribution.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1