EXT JS - 点击转移记录到弹出网格面板的存储

时间:2014-05-04 12:13:02

标签: extjs

这是我的弹出式标签。 我需要在store中的tab 2中从record到gridpanel给出一个值,以通过category_id从服务器端获取属性。在官方文档中搜索答案,但没有找到。 可以帮助我吗?

Ext.define('desk.view.CategoryPopup', {
    extend: 'Ext.window.Window',
    alias: 'widget.categorypopup',

    title: 'Change Category',
    layout: 'fit',
    autoShow: true,
    bdoyPadding: 10,

    initComponent: function(){
        this.items = [{
            xtype: 'tabpanel',
            items: [
                {
                    xtype: 'form',
                    title: 'Add / Edit / Delete Category',
                    items: [
                        {
                            xtype: 'textfield',
                            name: 'name',
                            fieldLabel: 'Parent Category'
                        },
                        {
                            xtype: 'textfield',
                            name: 'new',
                            fieldLabel: 'New Category'
                        },
                        {
                            xtype: 'textfield',
                            name: 'id',
                            fieldLabel: 'Category ID',
                            hidden: true
                        },
                        {
                            xtype: 'textfield',
                            name: 'parent',
                            fieldLabel: 'Parent ID',
                            hidden: true
                        }
                    ],
                    bodyPadding: 10
                },
                {
                    xtype: 'gridpanel',
                    alias: 'widget.categoryattr',
                    title: 'Attributes',
                    height: 350,
                    buttons: [{'text': 'Add attribute', 'action' : 'add-attribute'}],
                    columns: [
                        {
                            name: 'Name',
                            dataIndex: 'name'
                        }
                    ],
                    width: 300,
                    store: Ext.widget('categoryattributes')
                }
            ]
        }];

        this.buttons = [
            {
                text: 'Update',
                action: 'add'
            },
            {
                text: 'Delete',
                action: 'delete'
            }
        ];

        this.callParent(arguments);
    }
})

This is function in controller

editCategories: function(grid, record){
        var view = Ext.widget('categorypopup');
        view.down('form').loadRecord(record);
    }

1 个答案:

答案 0 :(得分:0)

你需要这样的东西:

editCategories: function(grid, record){
    var view = Ext.widget('categorypopup');
    view.down('form').loadRecord(record);
    Ext.Ajax.request({
        url: '/api/category/'+ record.getId() +'/attributes', //example url insert your webservice
        success: function(response){
            var attributes = Ext.decode(response.responseText);
            view.down('grid').getStore().loadData(attributes);
        }
    });
}

您需要一个带有网格模型的商店。