简体   繁体   English

复选框组中的boxLabel包装不正确(ExtJs4.2)

[英]Incorrect boxLabel wrap in a checkboxgroup (ExtJs4.2)

I'm having a problem with the box labels of the checkboxes being wrapped under the checkbox: 我在包装在复选框下面的复选框的框标签有问题:

http://jsfiddle.net/6pYWh/ http://jsfiddle.net/6pYWh/

        {
            xtype: 'checkboxgroup',
            columns: 1,
            vertical: true,
            items: [{
                boxLabel: 'Item 1',
                name: 'rb',
                inputValue: '1'
            }, {
                boxLabel: 'Item 2 with large box label does not wrap properly',
                name: 'rb',
                inputValue: '2',
                checked: true
            }]
        }

I need the wrap to be inline-block with both blocks in the same line, so i have to force the width of the second block to a certain size in order to accomplish that: 我需要将包装换行为同一行中的两个块为行内块,因此我必须将第二个块的宽度强制为一定大小才能完成此操作:

http://jsfiddle.net/595Md/ http://jsfiddle.net/595Md/

The problem is that i'm not seeing a way to accomplish this dynamicaly, so if you resize the west panel, the box label width will have to be recalculated and updated in order to use all the space now available and still maintain the wrap at the same level of the checkbox. 问题是我没有找到一种动态地完成此操作的方法,因此,如果您调整West面板的大小,则必须重新计算和更新框标签的宽度,以便使用现在可用的所有空间并仍将换行保持在相同级别的复选框。

Any toughts? 有困难吗?

Modify the following css selector. 修改以下css选择器。

.hello-world {
    white-space: normal;
    text-align: justify;
    margin: -10px 0 0 10px;
}

Then, try this. 然后,尝试这个。

Ext.require(['*']);

Ext.onReady(function () {

var viewport = Ext.create('Ext.Viewport', {
    layout: {
        type: 'border',
        padding: 5
    },
    defaults: {
        split: true
    },
    items: [{
        region: 'west',
        collapsible: true,
        header: false,
        split: true,
        width: 200,
        items: [{
            xtype: 'checkboxgroup',
            columns: 1,
            vertical: true,
            id: 'cb-group',
            items: [{
                boxLabel: 'Item 1',
                name: 'rb',
                inputValue: '1'
            }, {
                boxLabel: 'Item 2 with large box label does not wrap properly',
                name: 'rb',
                inputValue: '2',
                checked: true
            }, {
                boxLabel: 'Item 3',
                name: 'rb',
                inputValue: '3'
            }, {
                boxLabel: 'Item 4',
                name: 'rb',
                inputValue: '4'
            }, {
                boxLabel: 'Item 5',
                name: 'rb',
                inputValue: '5'
            }, {
                boxLabel: 'Item 6',
                name: 'rb',
                inputValue: '6'
            }],
            listeners: {
                beforerender: function() {
                    for (var i = 1; i < Ext.getCmp('cb-group').items.length; i++) {
                        if (Ext.getCmp('cb-group').items.items[i].boxLabel.length > 24 ) {
                            Ext.getCmp('cb-group').items.items[i].boxLabelCls = "hello-world";
                        }
                    }
                }
            }
        }]
    }, {
        region: 'center',
        html: 'center',
        title: 'Center'
    }, {
        region: 'south',
        title: 'South',
        height: 100,
        split: true,
        collapsible: true,
        html: 'south'
    }]
});
});

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

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