Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > JavaScript: Применение библиотек > [extjs] Динамический Grid


Автор: niro 8.11.2010, 19:28
Приветствую! Пытаюсь построить динамический 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;
}


JSON заголовка таблицы: 

Код

[
    {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":"[email protected]"},{"id":2,"first":"Wilma","last":"Flintstone","email":"[email protected]"},{"id":3,"first":"Pebbles","last":"Flintstone","email":"[email protected]"},{"id":4,"first":"Barney","last":"Rubble","email":"[email protected]"},{"id":5,"first":"Betty","last":"Rubble","email":"[email protected]"},{"id":6,"first":"BamBam","last":"Rubble","email":"[email protected]"}]}


Вся проблема в том, что columns: Ext.encode(response.responseText) не конвертирует содержимое JSON в javascript список. Или возможно проблема в том, что я пытаюсь неправильно работать с json.

Автор: ExSoft 18.12.2010, 00:38
http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.Store+http://dev.sencha.com/deploy/dev/docs/?class=Ext.grid.GridPanel???

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)