//岗位的名称
Ext.regModel('Units', {
fields: [{type:'string',name:'UnitID'},{type:'string',name:'UnitName'}]
});
var unitStore = Ext.create('Ext.data.Store', {
model: 'Units',
proxy:{
type:'ajax',
url:'/jxkh/app/jsp/jxkh_dafen_Mr.jsp?fg=11&uid='+uId,//查询
reader:new Ext.data.JsonReader({},[{name:'UnitID'},{name:'UnitName'}])
}, autoLoad:true
});
//下级岗位的名称
Ext.regModel('State', {
fields: [{type:'string',name:'value'},{type:'string',name:'text'}]
});
// The data store holding the states
var store = Ext.create('Ext.data.Store', {
model: 'State',
proxy:{
type:'ajax',
url:'/jxkh/app/jsp/jxkh_dafen_Mr.jsp?fg=1',//查询
reader:new Ext.data.JsonReader({},[{name:'value'},{name:'text'}])
}
});
//store.load();//加载页面时不加载 点击后加载,
pageVar.toolPanel = Ext.create('Ext.form.Panel',{
height:45,
layout:{type:'absolute'},
region:'north',
items:[
{
id:'comb',
xtype: 'combo',
width: 270,
fieldLabel: ' 岗位',
listConfig:{
loadingText:'正在加载信息'
},
triggerAction:'all',
store:unitStore,
valueField:'UnitID',
displayField:'UnitName',
labelAlign:'right',
queryMode:'remote',
emptyText:' 全 部 ',
x: -50,
y: 10,
listeners:{
select:function(combo, record,index){
try{
var parent=Ext.getCmp('combo1');
parent.clearValue();
store.load({params:{ppostid:this.value}});
}
catch(ex){
Ext.MessageBox.alert("错误","数据加载失败。");
}
}
}
},
{
id:'combo1',
xtype: 'combo',
width: 260,
fieldLabel: ' 下级岗位',
listConfig:{
loadingText:'正在加载信息'
},
triggerAction:'all',
queryMode: 'local', //这里要修改为local
selectOnFocus:true,
forceSelection: true,
allowBlank:false,
editable: true,
triggerAction:'all',
store:store,
valueField:'value',
displayField:'text',
labelAlign:'right',
emptyText:' 全 部 ',
x: 220,
y: 10
},
{
id:'dfd',
xtype: 'datefield',
fieldLabel: '日期',
labelAlign: 'right',
format:'Y-m-d',
value:nowTm,
x: 470,
y: 10
},
{
xtype: 'button',
width: 80,
text: '查询',
handler:queryBtn,
x: 730,
y: 10
}
]
});
--------------------------------返回json格式-----------------------------------
/**
* 输出查询串
*/
private void UnitInfoJSON(RSTable rs,HttpServletResponse resp){
PrintWriter out = null;
StringBuffer sb = new StringBuffer();
try
{
out = resp.getWriter();
if(rs != null && rs.getRowCount() > 0)
{
out.print("[");
sb.append("[");
for(int i = 0; i < rs.getRowCount(); i++)
{
out.print("{UnitID:'" + rs.getValueAt(i, 0) + "',UnitName:'" + rs.getValueAt(i, 1) + "'}");
sb.append("{UnitID:'" + rs.getValueAt(i, 0) + "',UnitName:'" + rs.getValueAt(i, 1) + "'}");
if(i != rs.getRowCount() - 1){
out.print(",");
sb.append(",");
}
}
out.print("]");
sb.append("]");
}
}
catch(IOException e)
{
out.print("]");
sb.append("]");
e.toString();
}
}