hunter_720
2008-06-24 15:36 阅读 174

ext grid分页出错问题

我要做ext grid分页,按例子做一直做不出来,在firebug上显示错误如下:
[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: javascript: eval(__firebugTemp__); :: anonymous :: line 1" data: no]

而且好像没用调用到HttpProxy中设置的action. HttpProxy设置的url为:./adminList.do 我的js文件目录在\WebRoot\js\jsfile\中,名为superAdminConsole.js, 我的action的path为/adminList .这样设置HttpProxy的url应该没有错吧,而且我也设置过../adminList.do或者是/adminList.do和adminList.do,结果都不行. 只要把store加到grid上就报上面的错,而且后台并没有显示调用到action中的方法.

具体代码如下:
superAdminConsole.js (节选与grid相关的):
[code="java"]
var AdminRecord = new Ext.data.Record.create([
{name:'id'},
{name:'username'},
{name:'realname'},
{name:'gender'},
{name:'role'},
{name:'department'}
]);

     var adminReader = new Ext.data.JsonReader({
    totalProperty:"results",
    root:"rows",
    id:"id"
},AdminRecord);

     var adminStore = new Ext.data.JsonStore({
    proxy:new Ext.data.HttpProxy({url:'./adminList.do'}),
    reader:adminReader
});

     //执行这句时出错的
     adminStore.load({params:{start:0,limit:10}});

//Admin列表
var adminListGrid = new Ext.grid.GridPanel({
    title:"Admin列表",
    height:380,
    columns:[new Ext.grid.RowNumberer(),
    {header:"Id",dataIndex:"id",sortable:true,hidden:true},
    {header:"用户名",dataIndex:"username",sortable:true},
    {header:"真实姓名",dataIndex:"realname",sortable:true},
    {header:"性别",dataIndex:"gender",renderer:showGender},
    {header:"角色",dataIndex:"role"},
    {header:"部门",dataIndex:"department",sortable:true}],
    store:adminStore,
    bbar:new Ext.PagingToolbar({
    pagesize:10,
    store:adminStore,
    displayInfo:true,
    displayMsg:'显示第{0}到{1}条数据,共{2}条',
    emptyMsg:"没有数据",
    beforePageText:"第",
    afterPageText:'页 共{0}页'
    })
});

[/code]

adminList.do 文件:
[code="java"]
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
SuperAdminBean superAdmin = (SuperAdminBean)request.getSession().getAttribute("person");

    String start = request.getParameter("start");
    String limit = request.getParameter("limit");
    System.out.println(start + "   " + limit);
    JSONObject json = null;
    try {
        int index = Integer.parseInt(start);
        int pageSize = Integer.parseInt(limit);
        List adminList = superAdmin.listCustomersByRole("Admin");
        json = JSONUtil.toJSONForPage(adminList,0,10);
    //为了显示是否输入正确的json.    
              System.out.println(json.toString());
        response.getWriter().write(json.toString());        
    } catch(Exception ex) {
    }
    return null;
}

输出的json为:
{"results":21,"rows":[{"department":"市场部","gender":"male","id":2,"post":"","realname":"leikai","role":"Admin","username":"lk"},{"department":"市场部","gender":"male","id":4,"post":"","realname":"leikai1","role":"Admin","username":"lk1"},{"department":"技术部","gender":"male","id":5,"post":"","realname":"leikai2","role":"Admin","username":"lk2"},{"department":"人事部","gender":"male","id":6,"post":"","realname":"leikai3","role":"Admin","username":"lk3"},{"department":"财务部","gender":"male","id":7,"post":"","realname":"leikai4","role":"Admin","username":"lk4"},{"department":"市场部","gender":"male","id":8,"post":"","realname":"leikai5","role":"Admin","username":"lk5"},{"department":"人事部","gender":"male","id":9,"post":"","realname":"leikai6","role":"Admin","username":"lk6"},{"department":"技术部","gender":"male","id":10,"post":"","realname":"leikai7","role":"Admin","username":"lk7"},{"department":"人事部","gender":"male","id":11,"post":"","realname":"leikai8","role":"Admin","username":"lk8"},{"department":"人事部","gender":"male","id":12,"post":"","realname":"leikai9","role":"Admin","username":"lk9"}]}
[/code]

请大家帮我看看!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    iteye_5994 iteye_5994 2008-06-25 09:08

    不要用JsonStore,直接用Store,我在建Grid时用JsonStore就没成功读出数据过

    点赞 评论 复制链接分享
  • awfwxf awfwxf 2008-06-24 20:30

    adminStore.load({params:{start:0,limit:10}});

    这句话放在最后面试到看下...

    点赞 评论 复制链接分享

相关推荐