传奇经理人手游论坛:extjs 下拉框远程获取数据源问题
来源:百度文库 编辑:偶看新闻 时间:2024/05/06 02:38:25
1.下面这个是获取客户端数据源
{ fieldLabel: "入库公司",
xtype: "combo",
width:200,
name: "comp_id",
hiddenName: "comp_id",
editable: false,
mode: "local",
displayField: "show",
valueField: "value",
triggerAction: "all",
value: "1",
store: new Ext.data.SimpleStore({
fields: ["show", "value"],
data: [["贵州燃气集团物资贸易有限公司", "1"], ["贵州燃气(集团)有限责任公司", "2"]]
})
}
2.下面这个获取的是远程服务器数据源
//获取所用供货公司json的store
superstore = new Ext.data.JsonStore({
url: "/ashx/supls.ashx?action=lis",
//autoLoad:true,
fields: ["Name", "Supp_id"]
//data: [["贵州燃气集团物资贸易有限公司", "1"], ["贵州燃气(集团)有限责任公司", "2"]]
});
superstore.load();
{
fieldLabel: "供货单位",
width: 200,
name: "supp_name",
xtype:"combo",
hiddenName:"supp_name",
displayField: "Name",
valueField: "Supp_id",
//mode: "remote",
mode:'local',
triggerAction: "all",
store: superstore
}
从extjs API看来远程获取数据源应该设置mode='remote'.但是这么设置它只有在火狐浏览器显示正常,在IE本跟就无法显示,
就这么一个问题折腾了我半天,所以不论是远程获取数据,还是客户端数据源都给mode='local',这样无论你是火狐还是IE都能够正确显示了
设置默认值
listeners: {
afterRender: function (combo) {
var dfv=superstore.getAt(0).get("Supp_id");
combo.setValue(dfv); //同时下拉框会将与name为firstValue值对应的 text显示
}
}
获取选中的文本值text
var suptext = Ext.get('suppID').dom.value;//获取下拉框选中文本值