简体   繁体   English

extJs列布局问题

[英]extJs column layout issue

I have 3 extJs Windows. 我有3个extJs Windows。 Each have some form control and then two tabs that display chart. 每个都有一个窗体控件,然后有两个显示图表的选项卡。 Currently all windows appear at the same place and i have to drag them to make them stand in a row like this | 当前所有窗口都出现在同一位置,我必须拖动它们以使它们像这样| | | | | . How can i create a 3 columns on screen and place each window in one of them. 我如何在屏幕上创建3列并将每个窗口放在其中之一中。 Please find the code of one of the window below. 请在下面的窗口之一中找到代码。 And yes i have seen this link http://dev.sencha.com/deploy/ext-4.0.7-gpl/examples/layout/table.html but it doesnt help my cause. 是的,我已经看到了此链接http://dev.sencha.com/deploy/ext-4.0.7-gpl/examples/layout/table.html,但这对我的事业没有帮助。 None of the content is displayed if i create 3 column layout like the what's mentioned in the link. 如果我创建3列布局(如链接中提到的内容),则不会显示任何内容。 Please assume that all of windows have the same code and suggest a way. 请假定所有窗口都具有相同的代码,并建议一种方法。 One more thing, i have closable, and maximizable feature in all of the windows.Thanks. 还有一件事,我在所有windows中都具有可关闭且可最大化的功能。谢谢。

var win = Ext.create('Ext.Window', {
    id: 'r1',
    width: eachWindowWidth,
    height: eachWindowHeight,
    hidden: false,
    maximizable: true,
    title: 'Registered Hosts',
    renderTo: Ext.getBody(),
    tbar: [{
        xtype: 'combo',
        width: 50,
        store: optionRegistered,
        mode: 'local',
        fieldLabel: '',
        name: 'answer',
        anchor: '90%',
        displayField: 'answer',
        valueField: 'id'
    }, {
        xtype: 'datefield',
        width: 90,
        name: 'time',
        fieldLabel: '',
        anchor: '90%'
    }, {
        xtype: "label",
        width: 20,
        fieldLabel: text,
        name: 'txt',
        text: 'to'
    }, {
        xtype: 'combo',
        id: 'c22devices',
        width: 50,
        store: optionRegistered,
        mode: 'local',
        fieldLabel: '',
        name: 'answer',
        anchor: '90%',
        displayField: 'answer',
        valueField: 'id'
    }, {
        xtype: 'datefield',
        id: 'cl22devices',
        width: 90,
        name: 'time',
        fieldLabel: '',
        anchor: '90%'
    }, {
        xtype: 'button',
        text: 'Ok'
    }],
    items: [

    {
        xtype: "label",
        fieldLabel: text,
        name: 'txt',
        text: text
    }, {
        xtype: 'tabpanel',
        id: "tabs1",
        activeTab: 0,
        width: eachTabWidth,
        height: eachTabHeight,
        plain: true,
        defaults: {
            autoScroll: true,
            bodyPadding: 10
        },
        items: [{
            title: 'Normal Tab',
            items: [{
                id: 'chartCmp1',
                xtype: 'chart',
                height: 300,
                width: 300,
                style: 'background:#fff',
                animate: true,
                shadow: true,
                store: storeRouge,
                axes: [{
                    type: 'Numeric',
                    position: 'left',
                    fields: ['total'],
                    label: {
                        renderer: Ext.util.Format.numberRenderer('0,0')
                    },
                    grid: true,
                    minimum: 0
                }, {
                    type: 'Category',
                    position: 'bottom',
                    grid: true,
                    fields: ['date'],
                }],
                series: [{
                    type: 'column',
                    axis: 'left',
                    highlight: true,
                    tips: {
                        trackMouse: true,
                        width: 140,
                        height: 28,
                        renderer: function (storeItem, item) {
                            this.setTitle(storeItem.get('date') + ': ' + storeItem.get('total') + ' $');
                        }
                    },
                    label: {
                        display: 'insideEnd',
                        'text-anchor': 'middle',
                        field: 'total',
                        renderer: Ext.util.Format.numberRenderer('0'),
                        orientation: 'vertical',
                        color: '#333'
                    },
                    xField: 'date',
                    yField: 'total'
                }]
            }]
        }, {
            title: 'Table View',
            xtype: 'grid',
            id: "gridChart1",
            width: 200,
            height: 200,
            collapsible: false,
            store: storeRouge,
            multiSelect: true,
            viewConfig: {
                emptyText: 'No information to display'
            },
            columns: [{
                text: 'Devices',
                flex: 50,
                dataIndex: 'date'
            }, {
                text: 'Pass',
                flex: 50,
                dataIndex: 'total'
            }]
        }]
    }],
    listeners: {

        resize: function () {
            Ext.getCmp("tabs1").setWidth(this.width);
            Ext.getCmp("tabs1").setHeight(this.height);
            Ext.getCmp("chartCmp1").setWidth(this.width * 100 / 100);
            Ext.getCmp("gridChart1").setWidth(this.width * 100 / 100);
            Ext.getCmp("gridChart1").setWidth(this.width * 100 / 100);
            Ext.getCmp("gridChart1").setWidth(this.width * 100 / 100);
        }
    }
});

The problem is, the Ext.Window while being descendand of Ext.Panel does not abide by the rules of the layout like normal Ext.Panels do, it floats by itself and is constrained only by the limits of the DOM element they're rendered to (body by default). 问题是,Ext.Window成为Ext.Panel的子对象时,它不像通常的Ext.Panels那样遵守布局规则,它自身浮动,并且仅受呈现它们的DOM元素的限制到(默认情况下为body)。

This means that you'll have to jump some loops to position and layout the windows manually. 这意味着您必须跳过一些循环才能手动定位和布局窗口。 You can also try to create some descendand class from Ext.WindowGroup to help you manage your windows and keep them nice and tidy. 您也可以尝试从Ext.WindowGroup创建一些Descendand类,以帮助您管理窗口并使窗口保持整洁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM