extjs ajax从后台取一条数据,这条数据是几条数据的累加,我怎么样才能够让这条数据显示在gird上呢?请高手帮忙,不胜感激。

解决方案 »

  1.   

    定义store,fields,最基本的ext内容,自己研究下api里的例子就是了
      

  2.   


       var store = Ext.create('Ext.data.JsonStore', {
                    storeId: 'simpsonsStore',
                    pageSize: itemsPerPage,
                    autoLoad: false,
                    remoteSort: false,
                    fields: ['Id', 'MaterialTypeId', 'UnitId', 'MaterialCode', 'MaterialName', 'ABCType', 'MtName', 'Spell', 'Price', 'PackType', 'ModelNumber', 'Standard', 'UnitName', 'MaterialQuality', 'DrawingNo', 'Status', 'MaxStorage', 'MinStorage', 'MNDesc', 'PackSize', 'PalletPackages', 'Re', 'SafeStorage', 'StandardDesc'],
                    proxy: {
                        type: 'ajax',
                        url: '<%= Url.Action("Search", "Material")%>',
                        reader: {
                            type: 'json',
                            root: 'rows',
                            totalProperty: 'totalCount'
                        }
                    }
                });            store.load({
                    params: {
                        start: 0,
                        limit: itemsPerPage
                    }
                });            var selModel = Ext.create('Ext.selection.CheckboxModel', { checkOnly: false });            var bbar = new Ext.PagingToolbar({
                    pageSize: itemsPerPage,
                    store: store,
                    displayInfo: true
                });            //创建 Grid
                var grid = Ext.create('Ext.grid.Panel', {
                    store: store,
                    stripeRows: true,
                    selModel: selModel,
                    autoHeight: true,
                    loadMask: true,
                    columns: [
                        { dataIndex: 'Id', hidden: true, sortable: true, width: 80 },
                        { dataIndex: 'MaterialTypeId', hidden: true, sortable: true, width: 80 },
                        { dataIndex: 'UnitId', hidden: true, sortable: true, width: 80 },
                        { header: '物资编码', sortable: true, dataIndex: 'MaterialCode', width: 100 },
                        { header: '物资名称', sortable: true, dataIndex: 'MaterialName', width: 100 },
                        { header: '拼音编码', sortable: true, dataIndex: 'Spell', width: 100 },
                        { header: 'ABC物资分类', sortable: true, dataIndex: 'ABCType', width: 100 },
                        { header: '物资类型', sortable: true, dataIndex: 'MtName', width: 100 },
                        { header: '价格', sortable: true, dataIndex: 'Price', width: 100 },
                        { header: '型号', sortable: true, dataIndex: 'ModelNumber', width: 100 },
                        { header: '状态', sortable: true, dataIndex: 'Status', width: 100 },
                        { header: '备注', sortable: true, dataIndex: 'Re', width: 100 }
                    ],
                    region: 'center'
                });
      

  3.   


    {
      "totalCount": 2,
      "rows": [
        {
          "Id": 3,
          "MtCode": "002",
          "MtName": "物资小类",
          "TypeName": "物资小类",
          "Sort": 1,
          "Re": "type desc小类型",
          "ParentTypeId": 1,
          "ParentTypeName": "所有类型"
        },
        {
          "Id": 2,
          "MtCode": "001",
          "MtName": "物资大类",
          "TypeName": "物资大类",
          "Sort": 1,
          "Re": "type desc",
          "ParentTypeId": 1,
          "ParentTypeName": "所有类型"
        }
      ]
    }