Приветствую! Пытаюсь построить динамический grid на основе json данных.
function Grid(urlHead, urlData){
var grid = new Ext.grid.GridPanel({});
Ext.Ajax.request({
loadMask: true,
url: urlHead,
success: function(response, callOptions){
var store = new Ext.data.JsonStore({
url: urlData,
});
grid = new Ext.grid.GridPanel({
store: store,
columns: Ext.encode(response.responseText),
height: 300,
title: 'Basic GridView',
iconCls: 'icon-grid',
bbar: new Ext.PagingToolbar({
pageSize: 10,
store: store,
displayInfo: true,
})
});
},
failure: function(response, callOptions) {}
});
return grid;
}
[
{header: "ID", width: 4, sortable: true, dataIndex: 'id'},
{header: "Name", width: 50, sortable: true, dataIndex: 'last'}
]
JSON таблицы:
{"success":true,"message":"Loaded data","data":[{"id":1,"first":"Fred","last":"Flintstone","email":"fred@flintstone.com"},{"id":2,"first":"Wilma","last":"Flintstone","email":"wilma@flintstone.com"},{"id":3,"first":"Pebbles","last":"Flintstone","email":"pebbles@flintstone.com"},{"id":4,"first":"Barney","last":"Rubble","email":"barney@rubble.com"},{"id":5,"first":"Betty","last":"Rubble","email":"betty@rubble.com"},{"id":6,"first":"BamBam","last":"Rubble","email":"bambam@rubble.com"}]}