在Sencha touch中设置搜索字段上的列表值

时间:2014-10-16 09:51:20

标签: javascript extjs sencha-touch-2

我在控制器上有这个方法

   onResponsibleSuggestListTap: function (list, index, target, record, event, eOpts) {
    var activityGeneral = this.getActivityGeneral();
    //set the text field value
    activityGeneral.down('#responsible').setValue(record.get('value'));
    console.log(record.get('value'));
    //hide out floating list
    this.getResponsibleSuggest().destroy();

    //clear the drop down list
    this.onClearResponsibleField();
},

并在视图中:

items: [
                {
                    xtype: 'container',
                    width: '60%',
                    padding: '0 3px 0 0',
                    items: [
                        {
                            xtype: 'searchfield',
                            itemId: 'responsibleSearchField',
                            placeHolder: 'introduces..."
                        }
                    ]
                }
       ]

但是我点击搜索字段中的项目后无法设置值,我做错了什么?

非常感谢!

1 个答案:

答案 0 :(得分:1)

按以下方式尝试更改

activityGeneral.query('searchfield[itemId=responsibleSearchField]')[0].setValue(record.get('value'));