Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Button 将不同的视图加载到视口中_Button_Extjs_View_Viewport - Fatal编程技术网

Button 将不同的视图加载到视口中

Button 将不同的视图加载到视口中,button,extjs,view,viewport,Button,Extjs,View,Viewport,我使用的是主视口。我用北面板做按钮。当我点击一个按钮时,我想在中心区域加载一个面板。我在architect allready中提出了一些观点 主视口 Ext.define('MyApp.view.MyViewport', { extend: 'Ext.container.Viewport', layout: { type: 'border' }, initComponent: function() { var me = this; Ext.applyIf(me, {

我使用的是主视口。我用北面板做按钮。当我点击一个按钮时,我想在中心区域加载一个面板。我在architect allready中提出了一些观点

主视口

Ext.define('MyApp.view.MyViewport', {
extend: 'Ext.container.Viewport',

layout: {
    type: 'border'
},

initComponent: function() {
    var me = this;

    Ext.applyIf(me, {
        items: [
            {
                xtype: 'container',
                height: 65,
                region: 'north',
                items: [
                    {
                        xtype: 'button',
                        height: 50,
                        maxHeight: 50,
                        maxWidth: 50,
                        minHeight: 50,
                        minWidth: 50,
                        style: 'margin: 5px;',
                        width: 50,
                        text: 'Home'
                    },
                    {
                        xtype: 'button',
                        height: 50,
                        maxHeight: 50,
                        maxWidth: 50,
                        minHeight: 50,
                        minWidth: 50,
                        style: 'margin: 5px;',
                        width: 50,
                        text: 'Verkoop'
                    },
                    {
                        xtype: 'button',
                        height: 50,
                        maxHeight: 50,
                        maxWidth: 50,
                        minHeight: 50,
                        minWidth: 50,
                        style: 'margin: 5px;',
                        width: 50,
                        text: 'Verhuur'
                    },
                    {
                        xtype: 'button',
                        height: 50,
                        maxHeight: 50,
                        maxWidth: 50,
                        minHeight: 50,
                        minWidth: 50,
                        style: 'margin: 5px;',
                        width: 50,
                        text: 'Magazijn'
                    },
                    {
                        xtype: 'button',
                        height: 50,
                        maxHeight: 50,
                        maxWidth: 50,
                        minHeight: 50,
                        minWidth: 50,
                        style: 'margin: 5px;',
                        width: 50,
                        text: 'TD'
                    },
                    {
                        xtype: 'button',
                        height: 50,
                        maxHeight: 50,
                        maxWidth: 50,
                        minHeight: 50,
                        minWidth: 50,
                        style: 'margin: 5px;',
                        width: 50,
                        text: 'Planning'
                    },
                    {
                        xtype: 'button',
                        height: 50,
                        maxHeight: 50,
                        maxWidth: 50,
                        minHeight: 50,
                        minWidth: 50,
                        style: 'margin: 5px;',
                        width: 50,
                        text: 'Facturen'
                    },
                    {
                        xtype: 'button',
                        height: 50,
                        maxHeight: 50,
                        maxWidth: 50,
                        minHeight: 50,
                        minWidth: 50,
                        style: 'margin: 5px;',
                        width: 50,
                        text: 'Klachten'
                    },
                    {
                        xtype: 'button',
                        height: 50,
                        maxHeight: 50,
                        maxWidth: 50,
                        minHeight: 50,
                        minWidth: 50,
                        style: 'margin: 5px;',
                        width: 50,
                        text: 'OPM'
                    }
                ]
            }
        ]
    });

    me.callParent(arguments);
}
例如,当我单击按钮“magazijn”时,我想将此视图加载到中心区域:

Ext.define('MyApp.view.Magazijn', {
extend: 'Ext.panel.Panel',

layout: {
    type: 'border'
},
title: 'Magazijn',

initComponent: function() {
    var me = this;

    Ext.applyIf(me, {
        items: [
            {
                xtype: 'panel',
                layout: {
                    type: 'border'
                },
                title: 'Pakbonnen',
                region: 'center',
                dockedItems: [
                    {
                        xtype: 'toolbar',
                        region: 'center',
                        dock: 'top',
                        items: [
                            {
                                xtype: 'button',
                                text: 'Beschadiging melden'
                            },
                            {
                                xtype: 'button',
                                text: 'Vermissing melden'
                            }
                        ]
                    },
                    {
                        xtype: 'gridpanel',
                        height: 150,
                        title: 'Uitgaande pakbonnen',
                        store: 'MyJsonStore',
                        region: 'north',
                        dock: 'top',
                        columns: [
                            {
                                xtype: 'gridcolumn',
                                dataIndex: 'string',
                                text: 'String'
                            },
                            {
                                xtype: 'numbercolumn',
                                dataIndex: 'number',
                                text: 'Number'
                            },
                            {
                                xtype: 'datecolumn',
                                dataIndex: 'date',
                                text: 'Date'
                            },
                            {
                                xtype: 'booleancolumn',
                                dataIndex: 'bool',
                                text: 'Boolean'
                            }
                        ],
                        viewConfig: {

                        },
                        dockedItems: [
                            {
                                xtype: 'pagingtoolbar',
                                width: 360,
                                displayInfo: true,
                                store: 'MyJsonStore',
                                dock: 'bottom'
                            }
                        ]
                    }
                ],
                items: [
                    {
                        xtype: 'gridpanel',
                        title: 'Retour pakbonnen',
                        store: 'MyJsonStore',
                        region: 'center',
                        columns: [
                            {
                                xtype: 'gridcolumn',
                                dataIndex: 'string',
                                text: 'String'
                            },
                            {
                                xtype: 'numbercolumn',
                                dataIndex: 'number',
                                text: 'Number'
                            },
                            {
                                xtype: 'datecolumn',
                                dataIndex: 'date',
                                text: 'Date'
                            },
                            {
                                xtype: 'booleancolumn',
                                dataIndex: 'bool',
                                text: 'Boolean'
                            }
                        ],
                        viewConfig: {

                        },
                        dockedItems: [
                            {
                                xtype: 'pagingtoolbar',
                                width: 360,
                                displayInfo: true,
                                store: 'MyJsonStore',
                                dock: 'bottom'
                            }
                        ]
                    }
                ]
            }
        ],
        dockedItems: [
            {
                xtype: 'toolbar',
                width: 150,
                region: 'west',
                dock: 'top',
                items: [
                    {
                        xtype: 'button',
                        text: 'Product zoeken'
                    }
                ]
            }
        ]
    });

    me.callParent(arguments);
}
var center = viewport.down('[region=center]');

var view = Ext.create('MyView');

center.add(view);
我该怎么做

  • 使中心区域成为具有卡片(或fit或tab)布局的容器

  • 调用中心区域上的add方法,添加组件

  • 要获取对视口的引用,请执行以下操作:

    var viewport = Ext.ComponentQuery.query('viewport')[0];
    
    要获取对中心区域的引用,请执行以下操作:

    Ext.define('MyApp.view.Magazijn', {
    extend: 'Ext.panel.Panel',
    
    layout: {
        type: 'border'
    },
    title: 'Magazijn',
    
    initComponent: function() {
        var me = this;
    
        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'panel',
                    layout: {
                        type: 'border'
                    },
                    title: 'Pakbonnen',
                    region: 'center',
                    dockedItems: [
                        {
                            xtype: 'toolbar',
                            region: 'center',
                            dock: 'top',
                            items: [
                                {
                                    xtype: 'button',
                                    text: 'Beschadiging melden'
                                },
                                {
                                    xtype: 'button',
                                    text: 'Vermissing melden'
                                }
                            ]
                        },
                        {
                            xtype: 'gridpanel',
                            height: 150,
                            title: 'Uitgaande pakbonnen',
                            store: 'MyJsonStore',
                            region: 'north',
                            dock: 'top',
                            columns: [
                                {
                                    xtype: 'gridcolumn',
                                    dataIndex: 'string',
                                    text: 'String'
                                },
                                {
                                    xtype: 'numbercolumn',
                                    dataIndex: 'number',
                                    text: 'Number'
                                },
                                {
                                    xtype: 'datecolumn',
                                    dataIndex: 'date',
                                    text: 'Date'
                                },
                                {
                                    xtype: 'booleancolumn',
                                    dataIndex: 'bool',
                                    text: 'Boolean'
                                }
                            ],
                            viewConfig: {
    
                            },
                            dockedItems: [
                                {
                                    xtype: 'pagingtoolbar',
                                    width: 360,
                                    displayInfo: true,
                                    store: 'MyJsonStore',
                                    dock: 'bottom'
                                }
                            ]
                        }
                    ],
                    items: [
                        {
                            xtype: 'gridpanel',
                            title: 'Retour pakbonnen',
                            store: 'MyJsonStore',
                            region: 'center',
                            columns: [
                                {
                                    xtype: 'gridcolumn',
                                    dataIndex: 'string',
                                    text: 'String'
                                },
                                {
                                    xtype: 'numbercolumn',
                                    dataIndex: 'number',
                                    text: 'Number'
                                },
                                {
                                    xtype: 'datecolumn',
                                    dataIndex: 'date',
                                    text: 'Date'
                                },
                                {
                                    xtype: 'booleancolumn',
                                    dataIndex: 'bool',
                                    text: 'Boolean'
                                }
                            ],
                            viewConfig: {
    
                            },
                            dockedItems: [
                                {
                                    xtype: 'pagingtoolbar',
                                    width: 360,
                                    displayInfo: true,
                                    store: 'MyJsonStore',
                                    dock: 'bottom'
                                }
                            ]
                        }
                    ]
                }
            ],
            dockedItems: [
                {
                    xtype: 'toolbar',
                    width: 150,
                    region: 'west',
                    dock: 'top',
                    items: [
                        {
                            xtype: 'button',
                            text: 'Product zoeken'
                        }
                    ]
                }
            ]
        });
    
        me.callParent(arguments);
    }
    
    var center = viewport.down('[region=center]');
    
    var view = Ext.create('MyView');
    
    center.add(view);
    
  • 使中心区域成为具有卡片(或fit或tab)布局的容器

  • 调用中心区域上的add方法,添加组件

  • 要获取对视口的引用,请执行以下操作:

    var viewport = Ext.ComponentQuery.query('viewport')[0];
    
    要获取对中心区域的引用,请执行以下操作:

    Ext.define('MyApp.view.Magazijn', {
    extend: 'Ext.panel.Panel',
    
    layout: {
        type: 'border'
    },
    title: 'Magazijn',
    
    initComponent: function() {
        var me = this;
    
        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'panel',
                    layout: {
                        type: 'border'
                    },
                    title: 'Pakbonnen',
                    region: 'center',
                    dockedItems: [
                        {
                            xtype: 'toolbar',
                            region: 'center',
                            dock: 'top',
                            items: [
                                {
                                    xtype: 'button',
                                    text: 'Beschadiging melden'
                                },
                                {
                                    xtype: 'button',
                                    text: 'Vermissing melden'
                                }
                            ]
                        },
                        {
                            xtype: 'gridpanel',
                            height: 150,
                            title: 'Uitgaande pakbonnen',
                            store: 'MyJsonStore',
                            region: 'north',
                            dock: 'top',
                            columns: [
                                {
                                    xtype: 'gridcolumn',
                                    dataIndex: 'string',
                                    text: 'String'
                                },
                                {
                                    xtype: 'numbercolumn',
                                    dataIndex: 'number',
                                    text: 'Number'
                                },
                                {
                                    xtype: 'datecolumn',
                                    dataIndex: 'date',
                                    text: 'Date'
                                },
                                {
                                    xtype: 'booleancolumn',
                                    dataIndex: 'bool',
                                    text: 'Boolean'
                                }
                            ],
                            viewConfig: {
    
                            },
                            dockedItems: [
                                {
                                    xtype: 'pagingtoolbar',
                                    width: 360,
                                    displayInfo: true,
                                    store: 'MyJsonStore',
                                    dock: 'bottom'
                                }
                            ]
                        }
                    ],
                    items: [
                        {
                            xtype: 'gridpanel',
                            title: 'Retour pakbonnen',
                            store: 'MyJsonStore',
                            region: 'center',
                            columns: [
                                {
                                    xtype: 'gridcolumn',
                                    dataIndex: 'string',
                                    text: 'String'
                                },
                                {
                                    xtype: 'numbercolumn',
                                    dataIndex: 'number',
                                    text: 'Number'
                                },
                                {
                                    xtype: 'datecolumn',
                                    dataIndex: 'date',
                                    text: 'Date'
                                },
                                {
                                    xtype: 'booleancolumn',
                                    dataIndex: 'bool',
                                    text: 'Boolean'
                                }
                            ],
                            viewConfig: {
    
                            },
                            dockedItems: [
                                {
                                    xtype: 'pagingtoolbar',
                                    width: 360,
                                    displayInfo: true,
                                    store: 'MyJsonStore',
                                    dock: 'bottom'
                                }
                            ]
                        }
                    ]
                }
            ],
            dockedItems: [
                {
                    xtype: 'toolbar',
                    width: 150,
                    region: 'west',
                    dock: 'top',
                    items: [
                        {
                            xtype: 'button',
                            text: 'Product zoeken'
                        }
                    ]
                }
            ]
        });
    
        me.callParent(arguments);
    }
    
    var center = viewport.down('[region=center]');
    
    var view = Ext.create('MyView');
    
    center.add(view);
    

    这就是我问题的答案!谢谢这是我问题的答案!非常感谢。