如何在 CellTable Gwt 中设置 ButtonCell 的样式?
我在互联网上搜索并找到了2个解决方案:
- 解决方案 1:使用urColumn.setCelLStyleNames("yourStyleName");
(向 ButtonCell 添加样式)
ButtonCell nextStepButton=new ButtonCell();
Column<String[], String> nextStepColumn = new Column<String[], String>(nextStepButton) {
@Override
public String getValue(String[] oneOrder) {
return oneOrder[11];
}
};
nextStepColumn.setCellStyleNames(getView().getRes().css().buttonCell());
在 CSS 中
.gwtButton, .buttonCell.getButton {
margin: 0;
padding: 5px 7px;
text-decoration: none;
cursor: pointer;
cursor: hand;
font-size:small;
background: black;
border:1px solid #bbb;
border-bottom: 1px solid #a0a0a0;
border-radius: 3px;
-moz-border-radius: 3px;
color: white;
}
我试过了,但什么也没发生。
-解决方案2:修改ButtonCell(https://code.google.com/p/google-web-toolkit/issues/detail?id=7044)
ButtonCell nextStepButton=new ButtonCell(){
// A native button cell doesn't have the gwt-button class, which makes it
// look weird next to other gwt buttons. Fix that here.
@Override
public void render(
final Context context,
final SafeHtml data,
final SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<button type=\"button\" class=\"gwt-Button\" tabindex=\"-1\">");
if (data != null) {
sb.append(data);
}
sb.appendHtmlConstant("</button>");
}
};
对于解决方案2,我可以看到差异(即 ButtonCell 的样式已更改)。但是,我没有“ gwt-Button
” css 类,而只有“ gwtButton
” css 类(参见上面的 css)。但是,当我在第二个代码中将“gwt-Button”更改为“gwtButton”时,sb.appendHtmlConstant("<button type=\"button\" class=\"gwtButton\" tabindex=\"-1\">");
什么也没发生。
那么,如何设置按钮单元格的样式以便它可以拾取gwtButton css class