简体   繁体   English

ExtJS 4:防止自动计算宽度

[英]ExtJS 4: Prevent auto-calculating of width

I'm using Ext.tab.Bar inside grid panel's tbar . 我在网格面板的tbar使用Ext.tab.Bar

My code is: 我的代码是:

...
tbar: [
    ...
    "->",
    this._getTabbar()
]
// where this._getTabbar() is:
GridPanel.prototype._getTabbar = function() {
    return Ext.tab.Bar({
        width: 850,
        items: [
            {text: "Grid's Tab #1", closable: false},
            {text: "Grid's Tab #2", closable: false},
            {text: "Grid's Tab #3", closable: false},
            ...
            {text: "Grid's Tab #N", closable: false}
        ]
    });
}

As a result, I get correct top-toolbar, but buttons in the tabbar is too short and I can't see their labels. 结果,我得到了正确的顶部工具栏,但是标签栏中的按钮太短了,我看不到它们的标签。 It means that tab-button Grid's Tab #1 appears like Grid's T... 这意味着选项卡按钮Grid的Tab#1看起来像Grid的T ...

I've tried to manually add width parameter to the tab configuration: 我尝试将width参数手动添加到选项卡配置中:

{text: "Grid's Tab #N", ..., width: 150}

And nothing, ExtJS automaticaly calculates the same width for each button. 没什么,ExtJS自动为每个按钮计算相同的宽度。 I tried to set flex: false and again nothing. 我尝试设置flex: false和再次没有。

What I want to ask you is what should I do to prevent flex-like width calculating? 我想问你的是如何防止类似弯曲的宽度计算? If I create 100500 buttons with "The button with long-long-long-long label", I want to see full text in all buttons in the tabbar. 如果我使用“带有长-长-长-长-长标签的按钮”创建100500个按钮,则希望在标签栏中的所有按钮中看到全文。

Thanks for your help. 谢谢你的帮助。

I am a little confused. 我有点困惑。 Grid panel tbar config is meant for a toolbar. 网格面板tbar config用于工具栏。 The config for a tbar is typically: tbar的配置通常是:

tbar: [
  { xtype: 'button', text: 'Button 1' }
]

Toolbar is not limited to buttons. 工具栏不仅限于按钮。 Here is an example of a very busy toolbar with all kinds of fields http://jsfiddle.net/dbrin/PhAbR/embedded/result/ 这是一个非常繁忙的工具栏示例,其中包含各种字段http://jsfiddle.net/dbrin/PhAbR/embedded/result/

The tab bar on the other hand is for a tab panel. 另一方面,选项卡栏用于选项卡面板。 here is what the docs say: 这是文档所说的:

"TabBar is used internally by a TabPanel and typically should not need to be created manually" “ TabBar由TabPanel内部使用,通常不需要手动创建”

not that you couldn't :) So, are you trying to create a custom component with tabs? 不是,您不能:)那么,您是否要尝试创建带有标签的自定义组件? If so why not use the regular tab panel? 如果是这样,为什么不使用常规选项卡面板?

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

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