By utilizing the Custom Control functionality in Cognos, it is now possible to create dynamic search and select filters within report outputs. This feature enhances the interactivity of reports, mimicking the functionality of an Excel spreadsheet by allowing users to apply filters directly on column headers to refine data based on their requirements.
To achieve this functionality in Cognos, custom JavaScript code can be developed, stored in the Cognos directory, and integrated as a Custom Control within the reporting solution.
For this tutorial, we have prepared a custom JavaScript file, which has already been uploaded to your Cognos directory (e.g., Web Content > BI > Samples > JS).
Note: If you would like to request this JavaScript code, please contact us at [email protected].
Once the custom javascript file is uploaded to the backend, you can begin creating a new report or add it to any existing report by following below steps:
Drag and drop the desired items into the list to define the data for reporting.
After adding the list, navigate to the query and create an optional filter on a list item. This filter will be utilized in the Custom Control configuration.
Note: For this tutorial, we are using the Sales and Products fields from the Great Outdoors Sample data module.
The filter is applied to the Product Line field, with the parameter name set as ‘PL’.
Now go to report page, add a block on top of list and drag ‘Custom Control’ from Advanced tab
Click on custom control in page and update its properties as below:
Module path: \bi\samples\js\<CustomDynamincSelectSearch>\<DynamincSelectSearch>.js
Configuration:
While Custom Control still selected, click on ‘Add Dataset’ (+ icon).
And drag Product line in it so that we can apply filter on list output using custom control only.
Add a value prompt to the page and assign it the existing parameter name ‘PL.’ Set the Box Type property of the value prompt to None to ensure it is not displayed on the page.
The report is now ready for testing. Execute it to view the custom control, Product Line, displayed at the top of the list. This control is fully functional and can be used to filter the data within the list.
To replace the ‘Product Line’ heading in the list with a custom control, first click the ‘Lock Page Objects’ button to unlock the elements.
Drag the ‘Product Line’ custom control into the first column header of the list. After adding it, remove the header text ‘Product Line’ for a cleaner appearance.
Our custom control will now appear as a header in the list, enabling functionality similar to that of an Excel spreadsheet for filtering and sorting data.
In similar way, it can be done for additional columns in list.