【问题标题】:extjs grid column header word wrap not workingextjs网格列标题自动换行不起作用
【发布时间】:2017-04-20 20:31:19
【问题描述】:

在我的 extjs6 网格中,我的列标题不适合空间。如何仅在列标题中进行自动换行?这是我尝试过的方法,但不起作用。

                            xtype: 'grid',
                        title: 'Daily Performance',
                        itemId: 'performanceAccountDailyGridID',
                        bind: {
                            store: '{myDailyPerformanceAccountStore}'
                        },                            
                        margin: '10px 0px 10px 0px',
                        ui: 'featuredpanel-framed',
                        cls: 'custom-gridPerformance',
                        height: 400,
                        width: 800,
                        columns: [
                            {
                                header: 'Filedate',
                                dataIndex: 'filedate',
                                flex: 1
                            },

css

.custom-gridPerformance .x-column-header-inner .x-column-header-text {
white-space: normal;
}

【问题讨论】:

  • .custom-gridPerformance x-column-header { 永远不会匹配任何东西,这是一个错字吗?
  • 不是错字。只是不确定用于编辑标题的正确格式。应该是什么?
  • 因为x-column-header没有.前缀,所以它不匹配类名,它会尝试匹配标签名称为<x-column-header>的标签
  • 所以我只需要放一个 .在 x 列之前?

标签: css extjs grid


【解决方案1】:

您的 CSS 选择器应该嵌套到包含列标题文本的 .x-column-header-text 为止。只需提供 white-space: normal 就足够了。 所以你的 CSS 应该是:

   .custom-gridPerformance .x-column-header-inner .x-column-header-text {
    white-space: normal;
}

工作示例:

var store = Ext.create('Ext.data.Store', {
    fields: ['name', 'email', 'region'],
    data: [{
        name: 'xyz',
        email: 'xyz@xyz.com',
        region: 'Arizona'
    }, {
        name: 'xyz',
        email: 'xyz@xyz.com',
        region: 'Alaska'
    }, {
        name: 'xyz',
        email: 'xyz@xyz.com',
        region: 'Alaska'
    }, {
        name: 'xyz',
        email: 'xyz@xyz.com',
        region: 'Alabama'
    }]
});

Ext.create('Ext.grid.Panel', {
    store: store,
    width: 400,
      cls: 'custom-gridPerformance',
    renderTo: Ext.getBody(),
   
    columns: [{
        text: 'Name of zoro of life style',
        dataIndex: 'name',

    }, {
        text: 'Email',
        dataIndex: 'email',
        flex: 1,

    }, {
        text: 'State',
        dataIndex: 'region',
        
    }],
    

});
.custom-gridPerformance .x-column-header-inner .x-column-header-text {
    white-space: normal;
}
<link rel="stylesheet" href="https://cdn.sencha.com/ext/gpl/4.1.1/resources/css/ext-all.css"><!-- framework javascript --><script type="text/javascript" src="https://cdn.sencha.com/ext/gpl/4.1.1/ext-all-debug.js"></script>

【讨论】:

  • 很奇怪,当我运行代码 sn-p 时,我看到您的代码 sn-p 可以正常工作,但是当我输入代码时仍然无法正常工作。我更改了我的帖子和代码以反映您的 CSS,但仍然没有。
  • 您使用的是什么版本和主题?
  • extjs6 我相信,and "toolkit": "classic", /** * 此应用程序的主题名称。 */ "theme": "myCustomTheme", //"theme": "theme-triton",
  • .custom-gridPerformance .x-column-header-inner .x-column-header-text { 空白:正常;字体大小:9px; } .custom-gridPerformance .x-column-header-inner { 行高:正常; padding-top: 3px !important; padding-bottom: 3px !important;文本对齐:居中;最高:20%; }
  • 我尝试了这个解决方案并取得了一些成功。对我来说,问题是给定导致换行的特定列宽,换行有时会将标题向下推并与第一行部分重叠。也许在提交此解决方案之前测试一些场景。
猜你喜欢
  • 2011-01-01
  • 1970-01-01
  • 2013-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-11
相关资源
最近更新 更多