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);

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