这是我的代码,求高手解答,非常感谢!!!
jsp中
Ext.onReady(function(){
    // create the Data Store  
    var store = new Ext.data.JsonStore({
        root: 'list',
        totalProperty: 'totalCount',
        idProperty: 'threadid',
        remoteSort: true,
        fields: [
            'stuId', 'stuName', 'stuSex', 'StuClass'
        ],
        proxy: new Ext.data.HttpProxy({
            url:'list_json'
        }),
    });
    // trigger the data store load  
    store.load({params:{start:0, limit:5}});    var grid = new Ext.grid.GridPanel({
        width:550,
        height:300,
        title:'ExtJS.com - Browse Forums',
        store: store,
        trackMouseOver:false,
        disableSelection:true,
        loadMask: true,
        // grid columns  
        columns:[{
            header: "学号",
            dataIndex: 'stuId',
            width: 220,
            sortable: false
        },{  
            header: "姓名",
            dataIndex: 'stuName',
            width: 100,
            sortable: false
        },{  
            header: "性别",
            dataIndex: 'stuSex',
            width: 70,
            align: 'right',
            sortable: false
        },{  
            header: "班级",
            dataIndex: 'stuClass',
            width: 150,
            sortable: false
        }],  
        // paging bar on the bottom  
        bbar: new Ext.PagingToolbar({
            pageSize:5,
            store: store,
            displayInfo: true,
            displayMsg: 'Displaying topics {0} - {1} of {2}',
            emptyMsg: "No topics to display",
            items:[
                '-', {
                pressed: true,
                enableToggle:true,
                text: 'Show Preview',
                cls: 'x-btn-text-icon details',
                toggleHandler: function(btn, pressed){
                    var view = grid.getView();
                    view.showPreview = pressed;
                    view.refresh();
                }
            }]
        })
    });
    // render it  
    grid.render('gridview');
});            
struts.xml中
<package name="extjs" extends="json-default">
        <default-action-ref name="login" />
        <action name="*_json" class="studentAction" method="{1}">
            <result type="json"></result>
        </action>
    </package>
acton.中
public String list(){
//得到response对象
HttpServletResponse response = ServletActionContext.getResponse();
try {
PrintWriter out = response.getWriter();// 得到输出对象
System.out.println("执行到action了");
String list = studentBiz.getStudenPaginationInfoToJson(start, limit);
if (list != null) {
StringBuilder stulist = new StringBuilder();
stulist.append("{totalCount:36,list:");
stulist.append(list);
stulist.append("}");
response.setCharacterEncoding("UTF-8");
out.print(stulist.toString());
// return null;
System.out.println("执行到action了3");
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
急求高手解答,感激不尽!!ext struts extjsjavascript

解决方案 »

  1.   

    var store = new Ext.data.JsonStore({
            totalProperty: 'totalCount',
            idProperty: 'threadid',
            remoteSort: true,
    root:'root', 
             proxy:{
    fields: ['stuId', 'stuName', 'stuSex', 'StuClass'], //顺序
                url:'list_json',
    type:'ajax',
    reader:'json'
    }
           
        });
      

  2.   

    Ext.define('MyApp.store.MyJsonStore', {
        extend: 'Ext.data.Store',        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
    //            autoLoad: true,
               fields: [{'stuId'},{ 'stuName'}, {'stuSex'}, {'StuClass'}], //
                storeId: 'store',
                
                proxy: {
                    type: 'ajax',                reader: {
                        type: 'json',
                        root: 'list'
                    }
                }
            }, cfg)]);
        }
    });