【问题标题】:Append custom css class to default class of FormItem in SmartGWT将自定义 css 类附加到 SmartGWT 中 FormItem 的默认类
【发布时间】:2013-03-05 18:03:59
【问题描述】:

如果我们没有明确设置类,SmartGWT 将默认设置某些 FormItem 的 css 类。例如,TextItem 将如下所示:

<input ... class="textItem" ...>

SmartGWT 中有一个方法可以为某些 FormItem 显式设置 css 类:

textItem.setTextBoxStyle("foo");

但是这个方法删除了所有以前的 css 类,包括默认类。有没有办法不删除而是将一些自定义类附加(或插入)到 FormItem?我想得到以下结果:

<input ... class="textItem foo" ...> or

SmartGWT 将根据触发的事件在用户交互期间更改最后一个 css 类。所以我会在默认类之前插入我的自定义类,以保持 FormItem 看起来相同:

<input ... class="foo textItem" ...>
<input ... class="foo textItemFocused" ...>
<input ... class="foo textItemDisabled" ...> ect.

可以吗?

【问题讨论】:

    标签: java css gwt smartgwt smartclient


    【解决方案1】:

    我从未使用过 SmartGWT,所以这可能不是最好的解决方案。

    您可以使用getTextBoxStyle (Javadoc) 获取类字符串,然后将其添加到您自己的类中并重新设置。

    如果您打算稍后删除该类,您只需要“保存”您的 css 类。

    【讨论】:

    • 感谢您的回答!但我已经尝试过 getTextBoxStyle() 并且它总是返回 null。我想 SmartGWT 在实际呈现页面之前将默认类设置在其内部深处。
    猜你喜欢
    • 2018-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-07
    • 2011-06-10
    • 1970-01-01
    • 2011-01-22
    相关资源
    最近更新 更多