Eclipse Birt-使用事件处理程序动态设置样式单元格表 [英] Eclipse Birt - Set style cell table dynamically with Event Handler

查看:356
本文介绍了Eclipse Birt-使用事件处理程序动态设置样式单元格表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在报表中有Birt表,并且我想创建一个处理程序类,如果单元格包含列的最大值,则该处理程序类将动态更改表中单元格的样式颜色.

I have Birt table in a report and i want to create a handler class that change the style color of the cell in the table dynamically if the cell contains the max of the column.

我首先尝试此操作,然后将类挂接到表报告的行上.

I try this for first step and i hooked the class to the row of the table report.

public class RowMinMax implements IRowEventHandler
{

  public void onCreate(IRowInstance rowInstance, IReportContext reportContext)
  {
      double max=0;             
      IRowData rowData = rowInstance.getRowData();
      double cellValue = (double) rowData.getColumnValue("nameColumn");

      if(cellValue>max)
      {
         //change cell style
      }
  } ... //OTHER METHOD INTERFACE
}

我找不到合适的方法来找到对象单元格并设置样式(例如,字体颜色为红色).

I can not find a suitable method to find the object cell and set the style (es. font color red).

我该如何解决?

谢谢

推荐答案

为什么这么复杂?您可以使用rptdesign文件中的Javascript实现此目的.无需使用自定义Java类. 首先,您应该使用BIRT的聚合列(在DataSet本身或Table项定义中)计算最大值(我们称其为"maxValue"). 接下来,您可以在报告的Initialize事件中定义如下函数:

Why so complicated? You can achieve this with Javascript in the rptdesign file. No need to use a custom Java class. First, you should compute the maximum (let's call it "maxValue") using BIRT's aggregation columns - either in the DataSet itself or in the Table item definition. Next, you can define a function like this in the reports's initialize event:

function modifyStyle(cell, row) {
    if (row["nameColumn"] >= row["maxValue"]) {
        cell.getStyle().borderLeftWidth = "3px";
        cell.getStyle().borderRightWidth = "3px";
    }
} 

在单元格的onCreate事件中,调用函数:

In the cell's onCreate event, call the function:

modifyStyle(this, row);

这篇关于Eclipse Birt-使用事件处理程序动态设置样式单元格表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆