关于ext入门的数据显示问题

前台代码

Ext.onReady(function(){

      var newFormWin;
        var userform;
        var data = [   
                    ['1', '2','3'],   
                    ['2', '2','3'],  
                    ['3', '2','3']


                ]; 
        // create the Data Store  数据
        var store = new Ext.data.Store({
             reader:new Ext.data.ArrayReader({
                 fields : [  
                           {name : 'member_id',type : 'string'},    
                           {name : 'member_name',type : 'string'} ,
                           {name : 'parent_id',type : 'string'}  
                          ]  
                 //new Ext.data.ArrayReader({
                // root: data,
                 //totalProperty: 1,
                // fields:["member_id","member_name","parent_id"]
             }),

            // load using script tags for cross domain, if the data in on the same domain as
            // this page, an HttpProxy would be better
            proxy:new Ext.data.MemoryProxy(data)
                //new Ext.data.HttpProxy({
                //url: 'http://localhost:8088/manager/getList.action'
            //})
        });
        store.load({params:{start:0, limit:10}});
        //分页显示用户数据
        var grid = new Ext.grid.GridPanel({

            autoHeight : true,
            width:700,//宽度
            //height:300,//高度
            title:'用户信息表',
            store: store,//数据        
            //加载的图标是否显示
            loadMask: false,
            //单行选中

            // grid columns列
            columns:[
           // new Ext.grid.CheckboxSelectionModel({singleSelect : false}),//复选框
            //new Ext.grid.RowNumberer(),//序号
            {
                // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
                header: "用户名",
                dataIndex: 'member_id',
                //align: 'center',
                sortable: false
            },{
                header: "年龄",
                dataIndex: 'member_name',
                //align: 'center',
                sortable: false
            },{
                header: "电话",
                dataIndex: 'parent_id',
                //align: 'center',
                sortable: false
            }]


        });
        // render it显示的层

        grid.render('grid');
        // trigger the data store load  加载用户

  })
  </script>




后台代码
public String getList() throws IOException{
        HttpServletResponse response=ServletActionContext.getResponse();
        try{
//      String json= "{"+
//        "metaData:{"+
//         " totalProperty:'results',"+
//          "root:'rows',"+
//          "fields:["+
//          "{name:'member_id',mapping:'member_id'},"+
//            "{name:'member_name',mapping:'member_name'},"+
//            
//            
//            "{name:'parent_id',mapping:'parent_id'}"+
//            
//            
//          "]"+
//          
//        "},"+
//        "results:"+1+","+
//        "rows:[{member_id:'1',member_name:'zhangsan',parent_id:'3'}]"+
//      
//      "}";
//      response.setCharacterEncoding("utf-8");
//      System.out.print(json.toString());
//      response.getWriter().write("{metaData:{ totalProperty:'results',root:'rows',fields:[{name:'member_id',mapping:'member_id'},{name:'member_name',mapping:'member_name'},{name:'parent_id',mapping:'parent_id'}]},results:1,rows:[{member_id:'1',member_name:'2',parent_id:'3'}]}");   
        response.getWriter().write("{totalProperty:1,data:[{member_id:'1',member_name:'2',parent_id:'3'},{member_id:'1',member_name:'2',parent_id:'3'}]}");
        }catch(Exception e){

        }
        return null;
    }

    之前在网上试了好几种例子,后台传的json字符串改了不知道多少次,前台页面一直是个loading,后来换成直接在前台把json数据写死,loading没了,也没数据。我是刚接触ext,不知道这是什么问题,不像java或者js,可以报错还能定位到问题。

    ![图片说明](https://img-ask.csdn.net/upload/201512/11/1449798974_130590.png)

2个回答

需要class, interface或enum
public String getList() throws IOException{
^ (犯错率:19.5% 犯错数:157 人)
需要class, interface或enum
try{
^ (犯错率:19.5% 犯错数:157 人)
需要class, interface或enum
}catch(Exception e){
^ (犯错率:19.5% 犯错数:157 人)
需要class, interface或enum
}
^ (犯错率:19.5% 犯错数:157 人)

多看点domo里面的示例,那个对象有哪些配置都搞错了



        var store = new Ext.data.Store({
            fields: [{ name: 'member_id', type: 'string' }, { name: 'member_name', type: 'string' }, { name: 'parent_id', type: 'string' }],
            /////////////本地数据
            data: data,
            proxy: { type: 'memory', reader: { type: 'array' } }
            ///////////远程数据,data.txt就是你data的内容,不包含var data=这些内容
            //proxy: { type: 'ajax', url: 'data.txt', reader: {type:'array'} },
            //autoLoad:true
        });
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问