定制Row的不同颜色

在系统的一览画面,我们有时候希望有的行的数据根据数据性质的不同而显示不同的颜色,

 Dinamica 默认只是处理的行的交叉色。

其他定制需要自己实现。

system win xp JP

Dinamica 2.1.4 with Ajax support.

正常的一览画面的显示部分,

调用的是默认的action  GenericOutput 。


配置文件部分如下:

<output>   

<classname>dinamica.GenericOutput</classname> 

<template>template.htm</template>  

<set-http-headers>true</set-http-headers>  

<content-type>text/html</content-type>

现在我们进行定制,

 

从GenericOutput继承一个新的类MyGenericOutput 。

 基类GenericOutput的onNewRow 方法 如下所示:  

public String onNewRow(Recordset rs, String rowTemplate) throws Throwable

 {



  /*

   * This code is used to alternate row colors,

   * the row template must include the special

   * field marker ${fld:_rowStyle} which will be replaced

   * by the style parameters set in web.xml. 

   */

  

  String style1 = getContext().getInitParameter("def-color1");

  String style2 = getContext().getInitParameter("def-color2");

  String currentStyle="";

  

  if (rowColor==0)

  {

   rowColor=1;

   currentStyle = style1;

  }

  else

  {

   rowColor=0;

   currentStyle = style2;

  }

  

  rowTemplate = StringUtil.replace(rowTemplate, "${fld:_rowStyle}", currentStyle);

  

  return rowTemplate;



 }
我们需要对onNewRow方法进行重写
public String onNewRow(Recordset rs, String rowTemplate) throws Throwable

	{

		String style1 = getContext().getInitParameter("def-color1");

		String style2 = getContext().getInitParameter("def-color2");

		String currentStyle="";

	

		if (EWWBDef.DATA_UPD_TYP_ADD.equals(rs.getValue("data_upd_typ")))

		{

			currentStyle = "class='specColor1'" ;

			rowTemplate = StringUtil.replace(rowTemplate, "${fld:_rowStyle}", currentStyle);

			

			return rowTemplate;

		}

		else if (EWWBDef.DATA_UPD_TYP_UPD.equals(rs.getValue("data_upd_typ")))

		{

			currentStyle = "class='specColor2'" ;

			rowTemplate = StringUtil.replace(rowTemplate, "${fld:_rowStyle}", currentStyle);

			

			return rowTemplate;

		}

		else if (EWWBDef.DATA_UPD_TYP_DEL.equals(rs.getValue("data_upd_typ")))

		{

			currentStyle = "class='specColor3" ;

			rowTemplate = StringUtil.replace(rowTemplate, "${fld:_rowStyle}", currentStyle);

			

			return rowTemplate;

		}

		else

		{

			return super.onNewRow(rs, rowTemplate) ;

			

		}

		

	}
上面的specColor1 ,specColor2,specColor3 需要在default.css中定制,
如下所示:
.grid tr.specColor1 td { background-color:#FFFFCC; } .grid tr.specColor2 td { background-color:#FAC5DA; } .grid tr.specColor3 td { background-color:#CC9900; }

经过上面的修改就可以按照自己的要求定制行的颜色了。
最后不能忘了,在config.xml中配置调用新做成的class.不是默认的那个GenericOutput。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值