Cognos Analytics

Cognos Analytics

Connect, learn, and share with thousands of IBM Cognos Analytics users! 

 View Only
  • 1.  Column Toggle for Lists - Native Custom Control!

    Posted 22 days ago

    Hi all, 

    I have been working on making my own native custom controls and decided to try and make a useful column toggle custom control for Cognos reporting List Data Container.

    The common solution to show/hide list columns dynamically is a cumbersome setup of conditional styles and render variables along with prompts to trigger report re-renders. I saw on the Scriptable Reports documentation that they have a method setColumnDisplay which doesn't work very well for pagination, only uses indexes, list title names, and will not work on lists that have group row spans, headers, or footers. It will throw errors very easily that would make users feel as though they did something wrong while using normal features of the on-demand toolbar. 

    I made a native custom control that will automatically look at the current report specification and the table rendered on the report page to dynamically get all the column titles and index them for you into a drop-down checkbox list. The configuration also allows for you to choose your column titles in the dropdown.

    This also will preserve the column visibility during pagination, disabled the column toggle feature during if a user filters a list with no data, or has group row spans, headers, and footers, and lastly doesn't require report re-queries. It feels fast and I think pretty seamless.

    You don't have to use it as a native custom control. I have two versions, and I think the regular ToggleColumn_CC should work for pretty much any version of Cognos Interactive Reports past 11.1. I only tested it on 12.0.4 and 12.1.0 but I think it should be ok for Cognos 11.1+. If anyone could test it on other versions that would be awesome. 

    Just for reference the native custom control is only supported on Cognos 12.0.3+.

    I hope to add the following features in the future:

    1. Column toggling for reports with group row spanning.
    2. Dynamically adjusting the list width when using "Scrollable area height" on list reports. This requires a more complex solution for adjusting column widths and is not considered in the setColumnDisplay method from Cognos.  

    I already have some ideas how to implement these but for now, I think this is a step up on any other solution out there. Feel free to reach out if you have any questions and feedback is very welcome.

    P.S.
    @Shaveta Srivastava also just posted a blog where he released a similar solution using native custom controls called a dynamic list however it doesn't preserve column state across pagination, and I had issues uploading the native control to my Cognos on demand instance. I think it is a good way to show how native custom controls can work however I think my version may be more useful for production scenarios.  




    ------------------------------
    Michael Webb
    ------------------------------

    Attachment(s)

    zip
    ToggleColumn_CC.zip   108 KB 1 version
    zip
    ToggleColumn_Native_CC.zip   111 KB 1 version


  • 2.  RE: Column Toggle for Lists - Native Custom Control!

    Posted 22 days ago

    For those who want to use it as a normal custom control here is the configuration for the custom control:

    {
      "configuration": {
        "Control Name": "List1",
        "Dropdown Button Label": "Toggle Columns",
        "Column Title String": "Title Text Content",
        "Customize Column Title Text": ["Column 1", "Column 2", "Column 3"]
      },
      "path": "../v1/ext/ToggleColumn_CC/js/ToggleColumn",
      "description": "A dropdown menu to toggle the visibility of report columns in a list. ",
      "width": "235px",
      "height": "36px",
      "COMMENT/Column Title String Options": [
        "Title Text Content",
        "Data Item Name",
        "Data Item Label",
        "HTML Rendered Text Content",
        "Custom Title Text"
      ]
    }
    

    Lastly, if you want to know what the Column Title String Options mean, this is how I get the labels for the checkboxes aligned with the column titles in the list. This is how they are coded:

    • Title Text Content: The full text in the List Column Title cell at the time of the report first render
    • Data Item Name: The Data Item name gathered from the Report specification used to render the report
    • Data Item Label: The Data Item Label gathered from the Report specification used to render the report
    • HTML Rendered Text Content: The expected HTML rendered text content in the List Column Title surmised from the report specification. Your results may vary depending on the kind of data you have in the title cell
    • Custom Title Text: This defaults the column titles to a comma separated list of strings in the "Customize Column Title Text" field. If there are less columns in the custom text field than exist in the table, Data Item Name will be used for un-customized titles. 


    ------------------------------
    Michael Webb
    ------------------------------



  • 3.  RE: Column Toggle for Lists - Native Custom Control!

    Posted 22 days ago

    I have updated and tested the Basic Custom Control to work correctly in 11.1.7, 12.0.4, and 12.1.0. 



    ------------------------------
    Michael Webb
    ------------------------------



  • 4.  RE: Column Toggle for Lists - Native Custom Control!

    Posted 19 days ago

    Thank you @Michael Webb for sharing the custom control. I will have a look. 



    ------------------------------
    Shaveta Srivastava
    ------------------------------



  • 5.  RE: Column Toggle for Lists - Native Custom Control!

    Posted 18 days ago

    Thanks, Michael.
    I've tested the extension on CA 12.0.4 and it works perfectly.

    Regards.



    ------------------------------
    Diego Campos
    ------------------------------