网格和窗体在同一视图extjs mvc

时间:2013-06-24 04:20:37

标签: extjs-mvc extjs4.2

我需要在同一视图上附加表单和网格,但无法执行此操作...如何扩展两者。

  

Ext.grid.Panel

  

Ext.form.Panel

我的观看代码就像......

Ext.define('CustomerService.view.customer.AfterAddingTemplate',{
extend:'Ext.grid.Panel',
alias:'widget.aftertemplate',
requires:['Ext.form.Panel','Ext.grid.Panel'],
id:'afteraddingtemplate',
store:'StockCategoryStore',
autoResizeColumns:true,
//layout:'fit',
columnLines:true,
stripeRows:true,
autoHeight:true,
autoWidth:true,
initComponent:function(){
this.items=[{
xtype:'textfield',
fieldLabel:'something'
}];
this.columns=[
{
header:'Select a template',
flex:2
},
{header:'Category'},
{header:'Warehouse'}];
this.callParent(arguments);     
}});

1 个答案:

答案 0 :(得分:1)

为什么你需要扩展两者?您只需扩展表单并将gridpanel添加为项目,例如

Ext.define('MyApp.view.MyForm', {
    extend: 'Ext.form.Panel',
    height: 250,
    width: 400,
    bodyPadding: 10,
    title: 'My Form',
    initComponent: function() {
        var me = this;
        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'textfield',
                    anchor: '100%',
                    fieldLabel: 'Label'
                },
                {
                    xtype: 'gridpanel',
                    title: 'My Grid Panel',
                    columns: [
                        {
                            xtype: 'gridcolumn',
                            dataIndex: 'string',
                            text: 'String'
                        }
                    ]
                }
            ]
        });
        me.callParent(arguments);
    }

});