添加新的attributeModifier时,如何删除以前的attributeModifier?

| 我有两列是orderbyborder链接。当我单击一个列时,我通过以下方式添加attributeModifier来更改列的颜色
add(new AttributeModifier(\"style\", true, new Model<String>(\"background-color:#80b6ed;\")));
这很好。但是,当我单击第二列时,第一列保持更改的颜色。但是我希望只有我单击的列才能包含此attributeModifier!     
已邀请:
        您不应该更改修饰符。 诀窍是让模型返回正确的值。因此,您将不用像总是返回相同常数值的
new Model<String>(\"background-color:#80b6ed;\")
那样:
new Model<String>() {
   @Override
   public String getObject() {
     if( columnName.equals( selectedColumn ) { //or something along these lines, to check if the current column is the selected one
        return \"background-color:#80b6ed;\";
     }
     return \"background-color:white;\";
   }
}
当然,这还意味着您可以在创建列时向每个列添加属性修饰符,而不必稍后再担心它们。     
        实现所需目标的另一种方法是通过Javascript将CSS类添加到所选行中(从旧类中删除该类)。     

要回复问题请先登录注册