本文介绍了GWT DataGrid多行标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一些GWT内容从CellTable迁移到DataGrid,主要是因为DataGrid的功能是在滚动时将标题行锁定在适当的位置.

I am migrating some GWT content from CellTable to DataGrid, mainly for the DataGrid's feature of locking the header row in place as you scroll.

对于CellTable,如果文本短语太长,则列标题文本将换行到下一行. CellTable的标头会动态增加高度.这是默认行为,我从未编辑过任何CSS文件.

With CellTable, the column header text would wrap to the next line if the text phrase was too long. The CellTable's header would dynamically grow in height. This was the default behavior, and I never edited any css files.

我可以在DataGrid中获得这种行为吗?我是否需要对主项目css文件进行更改,还是对clean.css进行更改?有没有一种编程的方法可以在DataGrid上设置属性?

Can I get this behavior in DataGrid? Do I need a change to my main project css file, or do I make a change to clean.css? Is there a programatic way to set a proprety on DataGrid?

我正在创建TextColumn等,并通过dataGrid.addColumn()添加;

I am creating TextColumn, etc. and adding via dataGrid.addColumn();

在此处查看示例,如果缩小浏览器窗口的宽度,则标题不会自动换行: http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwDataGrid

looking at the example here, the header doesn't wrap if you shrink the width of your browser window: http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwDataGrid

推荐答案

将此添加到您的CSS文件中:

Add this to your CSS file:

th {
    white-space: normal !important;
}

这篇关于GWT DataGrid多行标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 23:15