PDA

View Full Version : How to set value field dynamically in extjs



vijayakumar84
18 Apr 2013, 8:44 PM
Hi
can anybody tell how to set value field dynamically for combo in extjs.is there any equivalent method of setValueField in sencha is available in extjs

Thanks

girish.arjunagi
18 Apr 2013, 9:08 PM
vijayakumar,
You can use setValue() method to set the combo value dynamically.

vijayakumar84
18 Apr 2013, 11:19 PM
Hi,
I am asking about valueField in combo box

girish.arjunagi
19 Apr 2013, 1:37 AM
If you are intention is to set the value of the combo based on valueField, you can try the below code. Yes the setter for valueField is not there in combo.



var selectedModel = combo.findRecordByValue(valueField);
var value = selectedModel.get(valueField);
combo.setValue(value);

slemmon
20 Apr 2013, 9:02 AM
You can do combo.valueField = 'field2', but just know that if a selection was already made prior to dynamically setting valueField then the combo's value will be that of the previous valueField.