1

早上好,当我尝试从我的网络服务填充我的网格面板时遇到一些问题,结果是一个空的网格,谢谢你的提前。

// Create store

var myStore = new Ext.data.JsonStore({
    proxy: new Ext.data.HttpProxy({
        url: 'Service.asmx/GetPeople',
        headers: {
            'Content-type': 'application/json' 
        }
    }),
    root: 'd', 
    id: 'Id', 
    fields: ['Id', 'FistName', 'LastName', 'BirthDate'], 
    autoLoad: true
});

//Create grid to display data from store

var gridTest = new Ext.grid.Panel({
     store: myStore, // Our store
     renderTo: Ext.getBody(),
     forceFit: true,
     columns: [ // Grid columns
         { xtype: 'gridcolumn', width: 100, text: 'Id', dataIndex: 'Id', flex: 1 },
         { xtype: 'gridcolumn', width: 100, text: 'Nom', dataIndex: 'FirstName', flex: 1 },
         { xtype: 'gridcolumn', width: 100, text: 'Mail', dataIndex: 'LastName', flex: 1 },
         { xtype: 'gridcolumn', width: 100, text: 'Phone', dataIndex: 'BirthDate', flex: 1 }    
     ]
});

这是我的视口:

Ext.create('Ext.container.Viewport', {
    layout: "border",
    items: [{
        region: "north",
        height: 50,
        title: "Nord"
    }, {
        region: "south",
        height: 200,
        title: "sud",
        bodyStyle: 'background: #fffff;',
        border: false
    }, {
        region: "center",
        title: "centre",
        bodyStyle: 'background: #00000;',
        border: false,
        items: gridTest                                     
    }, {
        region: "west",
        width: 100,
        title: "ouest"
    }, {
        region: "east",
        width: 100,
        title: "est"
    }]
});

这是来自 FIREBUG MOZILLA FIREFOX 的回应:

{"d": [{
    "__type":"WebService4ExtJS.Model.Person", 
    "Id":0,
     "FirstName":"sami", 
     "LastName":"samibizani@gmail.com",
     "BirthDate":"23188219"
  }, {
     "__type":"WebService4ExtJS.Model.Person",
     "Id":1,"FirstName":"admin",
     "LastName":"admin@gmail.com",
     "BirthDate":"1111111"
  }, {
     "__type":"WebService4ExtJS.Model.Person",
     "Id":2,
     "FirstName":"user",
     "LastName":"user@gmail.com",
     "BirthDate":"2222222"
  }]
 }
4

1 回答 1

0

您的商店阅读器未定义:

reader: {
    type: 'json',
    root: 'd',
    idProperty: 'Id'
}

您可以在此处找到工作代码。

还有一个小错误:在 fields 数组中,您写FistName的不是FirstName.

于 2013-05-10T20:41:18.833 回答