我有一个返回 json 的 Web 服务。json是这样的:
aaa(
{
"data":
{
"error":0,
"totalProperty":3,
"groups":
[
{
"users":
[
{
"email":"natalia.busto@geograma.com",
"name":"Natalia",
"surname":"Busto Jimenez",
"rol":"user"
}
],
"description":"Grupo por defecto del dominio DEMO",
"name":"default",
"numUsers": 1
},
{
"users":
[
{
"email":"gorka.lopez@geograma.com",
"name":"Gorka",
"surname":"López Rivacoba",
"rol":"siteAdministrator"
},
{
"email":"endika.sanchez@geograma.com",
"name":"Endika",
"surname":"Sánchez Gutiérrez",
"rol":"user"
},
{
"email":"ignacio.gamez@geograma.com",
"name":"Ignacio",
"surname":"Gámez Ramírez",
"rol":"administrator"
}
],
"description":"Grupo nuevo creado para el dominio DEMO",
"name":"Group1",
"numUsers": 3
},
{
"users":[],
"description":"Group2 description",
"name":"Group2",
"numUsers": 0
}
],
"metadata":
{
"Request time":"16 ms"
}
},
"success":true
}
)
我想创建一个模型,然后创建一个存储数据以将参数描述、名称和 numUsers 放入网格中。
Ext.data.Model 是下一个:
Ext.define('Data', {
extend: 'Ext.data.Model',
hasMany: [{ model: 'Group', name: 'groups' }]
});
Ext.define("Group", {
extend: 'Ext.data.Model',
fields: [
{ type: 'string', name: 'description' },
{ type: 'string', name: 'name' },
{ type: 'int', name: 'numUsers' },
],
belongsTo: 'Data'
});
存储数据是下一个
this.store = Ext.create('Ext.data.Store', {
model: 'Data',
proxy: {
type: 'ajax',
url : 'http://100.100.100.165:8080/ums_servlet_1_0/services/Ums?request=getGroups&username=endika.sanchez@geograma.com&key=9856a705-0a2c-4f35-bbc9-f12d15ab234u&callback=aaa&extendedInfo=true&filter',
reader: {
type: 'json',
root: 'data',
idProperty: 'name'
}
},
});
网格面板是下一个
var itemsPerPage = 8; // set the number of items you want per page
this.store.load({
params:{
start:0,
limit: itemsPerPage
}
});
this.grid = new Ext.grid.Panel(
{
cls: this.CLASS_NAME + '_grid',
autoScroll: true,
store: this.store,
flex: 1,
style: 'border: solid rgb(234,234,236) 1px',
columns: [
{ header: 'Nombre', dataIndex: 'name',flex:1 },
{ header: 'Descripción', dataIndex: 'description',flex:2},
{ header: 'Número usuarios', dataIndex: 'numUser',flex:2},
{ xtype:'actioncolumn',
width:24,
menuDisabled: true,
items: [{
icon: 'img/edit.png',
iconCls: 'edit_delete',
tooltip: 'Editar',
handler: function(){}
}]
},
{ xtype:'actioncolumn',
width:24,
menuDisabled: true,
items: [{
icon: 'img/delete.png',
iconCls: 'edit_delete',
tooltip: 'Eliminar',
handler: function(){}
}]
}
],
dockedItems: [{
xtype: 'pagingtoolbar',
store: this.store, // same store GridPanel is using
dock: 'bottom',
displayInfo: true
}],
});
这会绘制网格,但不要将 json webservice 的数据放在网格内。问题是什么?