您的位置:首页 > 其它

ext 省市联动菜单

2009-12-16 10:41 323 查看
function getComboBox(store, valueF, displayF, label, name) {
return new Ext.form.ComboBox({
store: store,
fieldLabel: label,
allowBlank: false,
forceSelection: true,
valueField: valueF, // option.value
typeAhead: true,
displayField: displayF, // option.text
triggerAction: 'all',
emptyText: '请选择',
mode: 'local',
selectOnFocus: true,
width: 200,

name: name
});

}

function getRenderer(store, valueF, displayF) {
return function(value) {
var indexofvalue = store.find(valueF, value);
if (indexofvalue >= 0)
return store.getAt(indexofvalue).get(displayF);
return "未知项";
}
}

function getJsonStore(valueF, displayF, tablename) {
return new Ext.data.JsonStore({
root: 'list',
totalProperty: 'totalCount',
idProperty: valueF,
remoteSort: true,
fields: [
{ name: valueF }, { name: displayF }
],
proxy: new Ext.data.ScriptTagProxy({
url: '/management/procrequest/Proc_' + tablename + '.ashx?action=getlist'
})
});
}

function getAreaCombox(name) {
areakeyvalstore = getAreaStore("areaId", "areaName", 't_area',1);
return getComboBox(areakeyvalstore, 'areaId', 'areaName', '省', name);
}
var citystore;
function getCityCombox(name) {
citystore = getAreaStore("areaId", "areaName", 't_area',110000);
return getComboBox(citystore, 'areaId', 'areaName', '市', name);
}

//获得省列表

var pCombox = getAreaCombox("pAreaId");
var cityCombox = getCityCombox("areaIdtmp");
pCombox.store.load({
params: { "parentId[eq]": 1 }
});

//如果省列表选中了一项,则重新加载市列表
pCombox.on('select', function(box, newvar, oldvar){
cityCombox.setValue('');
cityCombox.store.reload({
params: { "parentId[eq]": pCombox.getValue() }
});

});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: