How To Pass Parameter To Group Sort

This recipe demonstrates on sorting group type by passing parameter using Java code.

Steps taken:

  1. Create a report template (PassParameterToGroupSort.rml) using the given datasource (FruitSales.ds).
  2. Add the following parameters into “Report->Parameters”:(Param1) Name = SortOption, Value = ${SortOption#choice(Company,Fruit)#Company}
    (Param2) Name = SortOrder, Value = ${SortOrder#choice(Ascending,Descending)#Ascending}
    (Param3) Name=SortGroupOn, Value = ${SortGroupOn#choice(None,Each Value,All)#None}
  3. Add the code into ‘Report->Open Properties->Script-> On Render Begin’:var sortOption = Parameters.get(“SortOption”)
    var sortOrder = Parameters.get(“SortOrder”)
    var sortGroupOn = Parameters.get(“SortGroupOn”)
    var Raw = getSection(0)Raw.getGroup(0).setField(sortOption);
    Raw.getGroup(0).setSortOrder(sortOrder);
    Raw.getGroup(0).setGroupOn(sortGroupOn);

To download the necessary files for this recipe, refer to the attached ZIP package.
HowToPassParameterToGroupSort.zip (4 KB)