开发者

Dojo ComboBox autocompletion

开发者 https://www.devze.com 2023-02-02 16:07 出处:网络
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.

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
    }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号