添加样式到扣式 [英] Adding style to a ButtonCell

查看:166
本文介绍了添加样式到扣式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我的问题被认为是最初指的是非常新手的水平,但我已经花了相当Ø大量的时间寻找答案。我曾经在一个GWT应用程序一个DataGrid使用,我重视特定细胞的小部件(即TextCell,扣式)的多样性。我关心的是如何,我可以通过自定义的CSS样式添加和处理到的扣式按钮。在code,它实现ButtonCells的列看起来如下:

 专栏< FilterInfo,字符串> delButtonColumn =新柱< FilterInfo,字符串>(新扣式()){  @覆盖
  公共字符串的getValue(FilterInfo对象){
    返回X;
  }
};

所以,我怎么能添加样式的按钮(而不是整个单元)?我怀疑,我也应该覆盖渲染功能,但我想不通的造型是如何应用

  @覆盖
公共无效渲染(上下文的背景下,FilterInfo对象,SafeHtmlBuilder SB){
  super.render(背景,对象,某人);
      ???
}


解决方案

您可以使用<一的setCellStyleNames()方法href=\"http://google-web-toolkit.google$c$c.com/svn/javadoc/2.4/com/google/gwt/user/cellview/client/Column.html#setCellStyleNames%28java.lang.String%29\"相对=nofollow>列以应用将被应用到列的每一个细胞的样式。你必须使用GWT 2.4这个工作。这将可能是类似的东西。请注意,code写任何IDE之外,因此它可能包含错误。

 专栏&LT; FilterInfo,字符串&GT; delButtonColumn =新柱&LT; FilterInfo,字符串&GT;(新扣式()){  @覆盖
  公共字符串的getValue(FilterInfo对象){
    返回X;
  }
};
delButtonColumn.setCelLStyleNames(yourStyleName);

和CSS的:

  .yourStyleName.gwt键式{
  //此处是您的风格
}

I know my question is considered initially to refer to the "very novice" level, but I have spent quite o lot of time on searching for the answer. I have used in a gwt application a DataGrid and I have attached a diversity of specific Cell widgets (i.e. TextCell, ButtonCell). My concern is how I can add and handle styling to the button of a ButtonCell through custom css. The code which implements the column of ButtonCells looks like as follows:

Column<FilterInfo, String> delButtonColumn = new Column<FilterInfo, String>(new ButtonCell()) {

  @Override
  public String getValue(FilterInfo object) {
    return "X";
  }
};

So, how can I add styling to the button (not to the entire Cell)? I suspect that I should also override the render function, however I cannot figure out how the styling is applied

@Override
public void render(Context context, FilterInfo object, SafeHtmlBuilder sb) {
  super.render(context, object, sb);
      ???
}

解决方案

You can use the setCellStyleNames() method in Column to apply a style that will be applied to every cell of the column. You have to use GWT 2.4 for this to work. It will probably be something like that. Please note that the code was written outside of any IDE, so it may contain errors.

Column<FilterInfo, String> delButtonColumn = new Column<FilterInfo, String>(new     ButtonCell()) {

  @Override
  public String getValue(FilterInfo object) {
    return "X";
  }
};
delButtonColumn.setCelLStyleNames("yourStyleName");

And the css :

.yourStyleName.gwt-Button{
  //your styling here
}

这篇关于添加样式到扣式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆