(这不是一个问题,我正在记录我使用 Ext JS 3.1.0 发现的解决方案。但如果您知道更好的解决方案,请随意回答!)
Ext JS Grid 对象的 Column 配置没有本机方法来允许换行文本,但有一个 css
属性来覆盖网格创建的 TD
元素的内联 CSS。
不幸的是,TD
元素包含一个包装内容的 DIV
元素,并且 Ext JS 样式表将该 DIV
设置为 white-space:nowrap
,因此覆盖 TD
CSS 没有任何作用。
我在我的主 CSS 文件中添加了以下内容,这是一个简单的修复方法,看起来似乎不会破坏任何网格功能,但允许传递给 DIV
的任何 white-space
设置。
.x-grid3-cell {
/* TD is defaulted to word-wrap. Turn it off so
it can be turned on for specific columns. */
white-space:nowrap;
}
.x-grid3-cell-inner {
/* Inherit DIV's white-space from TD parent, since
DIV's inline style is not accessible in the column
definition. */
white-space:inherit;
}
对每个人的情况可能不同,但对我有用,因为在互联网上搜索不到有效的解决方案,所以我想将其作为一个解决方案分享出来。