2002 JI Open Discussion Posted August 18, 2006 Share Posted August 18, 2006 By: Hagen - jemih Dynamic group order 2003-07-18 02:14 Hi, if I have got a report that has three data fields A, B and C. If I want to group by all three fields, is it possible to change the group order dynamically (ABC, CBA, BCA etc.)? Thanks, Hagen By: Ryan Johnson - delscovich RE: Dynamic group order 2003-07-18 09:20 Here's how I do it: 1. Set the ordering of the data (ie, 'order by A, B, C', 'order by 'C, B, A', etc.). Otherwise, changing the grouping won't work very well 2. Design the report to have the group expressions use the ?: operator to select the proper grouping based on a parameter you pass in. For example, given the String parameter groupType: <group name="group1"> <groupExpression> ($P{groupType}.charAt(0) == 'A')? $F{A} : ($P{groupType}.charAt(0) == 'B')? $F{B} : ($P{groupType}.charAt(0) == 'C')? $F{C} : null </groupExpression> </group> <group name="group2"> <groupExpression> ($P{groupType}.charAt(1) == 'A')? $F{A} : ($P{groupType}.charAt(1) == 'B')? $F{B} : ($P{groupType}.charAt(1) == 'C')? $F{C} : null </groupExpression> </group> <group name="group3"> <groupExpression> ($P{groupType}.charAt(2) == 'A')? $F{A} : ($P{groupType}.charAt(2) == 'B')? $F{B} : ($P{groupType}.charAt(2) == 'C')? $F{C} : null </groupExpression> </group> Good luck, Ryan By: Hagen - jemih RE: Dynamic group order 2003-07-18 12:17 That works fine! Thanks, Hagen Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now