想要list中的N在列中顯示為報廢,Y->良好.....
寫Java類:
package com.gecs.feeder;
import org.apache.commons.lang.StringUtils;
import org.extremecomponents.table.bean.Column;
import org.extremecomponents.table.core.TableModel;
import org.extremecomponents.table.intercept.InterceptColumn;
public class YNRIntercept implements InterceptColumn
{
?public void addColumnAttributes(TableModel arg0, Column arg1)
?{?}
?public void modifyColumnAttributes(TableModel arg0, Column arg1)
?{
??// TODO Auto-generated method stub
??String career = arg1.getPropertyValueAsString();
??if(StringUtils.contains(career, "Y"))
??{
???arg1.setValue("良好");
??}
??if(StringUtils.contains(career, "N"))
??{
???arg1.setValue("報廢");
??}
??if(StringUtils.contains(career, "R"))
??{
???arg1.setValue("維修");
??}
?}
}
---------------------------------------------------------------
這樣使用就OK了
<ec:column property="OKORNG" title="狀態" intercept="com.gecs.feeder.YNRIntercept"></ec:column>
另改變字體樣式了可以這樣:
String career = column.getPropertyValueAsString();
? ? ? ? if (StringUtils.contains(career, "xxxxx")) {
? ? ? ? ? ? column.setStyle("color:#e75a08;font-weight:bold;");
? ? ? ? } else {
? ? ? ? ? ? column.setStyle("color:black");
? ? ? ? }