extjs中怎么根据后台数据设置combox应该显示的值,

如我后台返回的是0 则让combox显示0对应的 (正常)
2025-05-13 07:35:51
推荐回答(2个)
回答(1):

//先来看combox执行选择的方法
var c = Ext.create('Ext.form.ComboBox', {});
//用这个方法可以选中数据
c.select(Object r);
//你要根据后台显示,只需要从store中抽出要选中的object就行了
Ext.Ajax.request({
    url: 'xxx',
    success: function (response) {
        var data = Ext.decode(response.responseText);
        //为他加载数据
        c.store.loadData(data , false);
        //这里的field应是selectvalue,而不是showvalue
        var index = c.store.find('store的field', 0);
        if (index != -1) {
            c.select(c.store.getAt(index));
        }
    }
});

回答(2):

xtype : 'combo',
//其他参数略

store : [[0:正常],[1:异常]],
value: 你传过来的值