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