在我的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;
}
答案 0 :(得分:3)
你的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>