服务器端代码: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没有填充进任何的值?求指点

解决方案 »

  1.   

    页面上 console.dir(roleStore) FF firebug 看一下
    而且你的一些写法要改一下 创建控件建议你都用 Ext.create( )这种形式去写
    eg:Ext.create(Ext.form.comboBox, {
        //
    })
      

  2.   

    我错了,后台代码没给出原来的版本,原来问题出在这,之前的函数返回值为String,并且返回的不是null,所以有问题,但是出现的这个问题是什么原因呢,浏览器上出现这个错误:
    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,就在这个基础上改了
      

  3.   

    不好意思 挺常事件没上了 我把我写的demo copy上来 你自己对照下吧
      

  4.   

    // combo
    {
    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"
    }]
    });
      

  5.   

    api那个你可以不用 直接在代理里面添加一个url如果你不是mvc的
    那么创建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都有实例 仔细看一看 才学都比较辛苦 坚持住就好
      

  6.   

    store好像需要先load一下吧,这样才有数据把。