服务器端代码:public void getRoleList() throws IOException{
String str = "{'datas':[{'roleID':0,'roleName':'超级管理员'},{'roleID':1,'roleName':'管理员'}]}";
ServletActionContext.getResponse().setContentType("text/json; charset=utf-8");
ServletActionContext.getResponse().getWriter().write(str);
}JSP页面代码:var roleStore = new Ext.data.JsonStore({
url:'<%=baseUrl %>/user_getRoleList.action',
root:'datas',
idProperty: 'roleID',
fields: ['roleID','roleName']
});
var roleManagerForm={
id:'roleManagerForm',
xtype:'form',
items:[
{
xtype:'fieldset',
title:'编辑角色权限',
items:[
{
id:'combox',
xtype:'combo',
hiddenName: 'user.roleID',
typeAhead: true,
mode : 'local',
emptyText: '角色名称',
triggerAction: "all",
valueField: 'roleID',
displayField: 'roleName',
store: roleStore,
editable: false,
};运行之后,为什么comboBox没有填充进任何的值?求指点
String str = "{'datas':[{'roleID':0,'roleName':'超级管理员'},{'roleID':1,'roleName':'管理员'}]}";
ServletActionContext.getResponse().setContentType("text/json; charset=utf-8");
ServletActionContext.getResponse().getWriter().write(str);
}JSP页面代码:var roleStore = new Ext.data.JsonStore({
url:'<%=baseUrl %>/user_getRoleList.action',
root:'datas',
idProperty: 'roleID',
fields: ['roleID','roleName']
});
var roleManagerForm={
id:'roleManagerForm',
xtype:'form',
items:[
{
xtype:'fieldset',
title:'编辑角色权限',
items:[
{
id:'combox',
xtype:'combo',
hiddenName: 'user.roleID',
typeAhead: true,
mode : 'local',
emptyText: '角色名称',
triggerAction: "all",
valueField: 'roleID',
displayField: 'roleName',
store: roleStore,
editable: false,
};运行之后,为什么comboBox没有填充进任何的值?求指点
而且你的一些写法要改一下 创建控件建议你都用 Ext.create( )这种形式去写
eg:Ext.create(Ext.form.comboBox, {
//
})
HTTP Status 404 - No result defined for action action.UserAction and result 1--------------------------------------------------------------------------------type Status reportmessage No result defined for action action.UserAction and result 1description The requested resource (No result defined for action action.UserAction and result 1) is not available.
原来的服务器代码:
public String getRoleList() throws IOException{
String str = "{'datas':[{'roleID':0,'roleName':'超级管理员'},{'roleID':1,'roleName':'管理员'}]}";
ServletActionContext.getResponse().setContentType("text/json; charset=utf-8");
ServletActionContext.getResponse().getWriter().write(str);
return "1";
}至于我为什么写成有返回值的,是因为之前用的ArrayStore,然后再JSP页面调用后台方法,填充ArrayStore,后来想用JsonStore,就在这个基础上改了
{
xtype:"combo",
fieldLabel:"账号列表",
labelAlign:"right",
labelWidth:80,
store: me.store,
emptyText:"请输入搜索条件",
displayField:"userName",
valueFiled:"userName",
queryModel:"remote",
allQuery:"all",
queryDelay:300,
triggerAction:"all",
listConfig:{
loadingText:"正在读取信息...",
maxHeight:100
},
width:300
}
// storeExt.define("DBO.store.Accounts",{
extend:"Ext.data.Store",
model:"DBO.model.Account",
autoLoad:true,
pageSize:20,
proxy:{
type:"ajax",
api:{
read:"/resources/app/data/TestAccounts.json",
update:"/resources/app/data/TestUpdateAccounts.json"
},
reader:{
type:"json",
root:"Accounts",
successProperty:"success"
},
simpleSortMode:true
},
sorters:[{
property:"accountId",
direction:"DESC"
}]
});
那么创建store
Ext.create(Ext.data.Store,{
model:"DBO.model.Account",
autoLoad:true,
pageSize:20,
proxy:{
type:"ajax",
url:"/resources/app/data/TestAccounts.json",
reader:{
type:"json",
root:"Accounts",
successProperty:"success"
},
simpleSortMode:true
},
sorters:[{
property:"accountId",
direction:"DESC"
}]
})记得用FF 看看网络返回的内容
官方demo都有实例 仔细看一看 才学都比较辛苦 坚持住就好