Tags 如何使用displaytag装饰表中的行
我正在使用显示标记显示表中的值。我想根据列中的值给表中的特定行上色,比如说“Y”,然后用红色给行上色。我该怎么做?我一直在查找使用decorator类和addRowClass方法的display标记的文档,但它太令人困惑了。有没有一种方法可以使用JavaScript实现这一点?我一直在使用下面我找到的JavaScriptTags 如何使用displaytag装饰表中的行,tags,Tags,我正在使用显示标记显示表中的值。我想根据列中的值给表中的特定行上色,比如说“Y”,然后用红色给行上色。我该怎么做?我一直在查找使用decorator类和addRowClass方法的display标记的文档,但它太令人困惑了。有没有一种方法可以使用JavaScript实现这一点?我一直在使用下面我找到的JavaScript 您可以为表设置decorator=decorator并重写addRowClass方法。 request.setAttributeCorator,new org.displayt
您可以为表设置decorator=decorator并重写addRowClass方法。
request.setAttributeCorator,new org.displaytag.decorator.TableDecorator{…} 您必须创建一个TableDecorator类,在这个类中您必须创建addRowClass方法,该方法返回您需要的css类,例如:
package com.example.decorator;
public class DisplayTagExampleDecorator extends TableDecorator {
@Override
public String addRowClass() {
try {
return ((ObjectVO) getCurrentRowObject()).isHaveClass() ?
* " bg-dark" : "";
}
catch(Exception e)
{
return "";
}
}
}
在jsp文件中,您必须修改decorator属性,如下所示:
您使用什么语言,在什么上下文中,在什么框架或SDK中?你的代码在哪里?我正在使用Java和struts 2框架
package com.example.decorator;
public class DisplayTagExampleDecorator extends TableDecorator {
@Override
public String addRowClass() {
try {
return ((ObjectVO) getCurrentRowObject()).isHaveClass() ?
* " bg-dark" : "";
}
catch(Exception e)
{
return "";
}
}
}