Dojo ComboBox autocompletion
I use Zend Framework to create a form element of type Zend_Dojo_Form_Element_ComboBox. I set dojox.data.QueryReadStore as a store type.
The final effect is I have got an input in my HTML. The store is queried and I receive a list of possible values. I can select one or enter my own. Everything is OK so far.
The data that is stored in the field is not an identifier of the store. The store data is like: {"identifier":"id","items":[ {"id":18,"d1":"xxxxxx","d2":"yyyyyyyyyy"}, {"id":22,"d1":"xxxxxx","d2":"zzzzzz"}, {"id":18,"d1":"xxxxxxaaaa","d2":"aaaaaaaaaaaa"} ],"label":"something"} Let's say d1 is taken as a value.
Now I want to use d2 to populate another field in a form. What should I do? Can I do it on a Zend's side? I have tried to dojo.connect to th开发者_如何学Pythone combo box, but do not know how to retrieve correct data from the store.
You can use dojo.connect
to connect to the onChange
event of the combo box. The combo box has a property item
that refers to current selected item in the data store. You can use it to get data from the store. For example:
dojo.connect(comboBox, 'onChange', function() {
if (comboBox.item) {
var d2 = store.getValue(comboBox.item, "d2");
//Use d2
}
});
精彩评论