Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Setting table groups in code (conditional grouping)(How to set dynamic table groups)
icon3.gif  Setting table groups in code (conditional grouping) [message #557855] Thu, 09 September 2010 05:03 Go to next message
Mark Howard is currently offline Mark Howard
Messages: 7
Registered: April 2010
Junior Member
Hello,

what's the best way in the latest birt version to set the groups for a table dynamically in code?

For example i want to have 2 groups for my table in the report: Group1 and Group2. Now i want to set the group on criterion in the code because the groups are based on an user input in the application. I work with a scripted data set that gets filled in the code.

So the questions are:
- Is the easiest way to set the criterion in the code?
- There is a better solution for such a task?

Thx for your help

[Updated on: Thu, 09 September 2010 06:36]

Report message to a moderator

Re: Setting table groups in code [message #557998 is a reply to message #557855] Thu, 09 September 2010 13:34 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

You can always change the group using the group expression. Something like:

if( params["Grp"].value == "Order" ){
row["ORDERNUMBER"];
}else{
row["PRODUCTCODE"];
}

You can also change it in the beforeFactory using some DE API like:
//TableHandle
var th =reportContext.getDesignHandle().findElement("MyTable");
//TableGroupHandle
//First group
var tgh = th.getGroups().get(0);
tgh.setKeyExpr("row[\"PRODUCTCODE\"]");
tgh.getTOC().setExpression("row[\"PRODUCTCODE\"]");
//DataItemHandle data item in group header
var di = reportContext.getDesignHandle().findElement("MyGroupLabel");
di.setResultSetColumn( "PRODUCTCODE" );

Note that the findElements require that you name your items

Jason


On 9/9/2010 5:03 AM, Mark Howard wrote:
> Hello,
>
> what's the best way in the latest birt version to set the groups for a
> table dynamically in code?
>
> For example i want to have 2 groups for my table in the report: Group1
> and Group2. Now i want to set the group on criterion in the code because
> the groups are based on an user input in the application. I work with a
> scripted data set that gets filled in the code.
>
> So the questions are:
> - Is the easiest way to set the criterion in the code?
> - There is a better solution for such a task?
>
> Thx for your help
icon14.gif  Re: Setting table groups in code (conditional grouping) [message #558067 is a reply to message #557855] Fri, 10 September 2010 01:58 Go to previous message
Mark Howard is currently offline Mark Howard
Messages: 7
Registered: April 2010
Junior Member
Thank you very much Jason, this was what i was looking for.
Previous Topic:Text not localized automatically
Next Topic:Joint Dataset
Goto Forum:
  


Current Time: Sat Aug 23 01:51:18 EDT 2014

Powered by FUDForum. Page generated in 0.01686 seconds