Skip to Content

Best Practice for dynamiclly hiding/displaying fields on View

We are searching for some best practice /guideline to hide certain fields on a view at certain conditions.

F.e.: On View BP_HEAD/AccountDetails the field BP_GROUP should only be visible if an account (customer) has not been saved yet.

In any other case the field should not be visible. Please keep in mind BP_HEAD/AccountDetails is reused at other places.

My first attempt was to override in Contextnode 'HEADER' the attributes BP_GROUP GET_A_BP_GROUP method and controll the field`s visibility via return value rs_sfw_data‚Äźreaction. But this attempt will render empty htmltablecells i.e. the webform shows whitespaces instead of labels/controls, which is pretty ugly in my opinion.

Hiding & displaying fields should be a common requirement, so is there any best practice approach leading to a webform without whitespaces but also providing the flexibility of GETTERs?

We also thought about using several View configurations, but as the views are used at several places (in this case f.e. also to edit an existing Account) and different fields might be required to be shown/hidden in different scenarios, this doesn`t seem to be an appropriate solution, as it would probably lead to a bunch of view configs.

Thanks for any feedback!

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Apr 13, 2016 at 08:13 AM

    Hi Oliver,

    As per my suggestion, there are three ways to achieve this functionality.

    1. Using multiple configurations and then writing logic in DO_CONFIG_DETERMINATION to determination Configuration at runtime based on attributes (in this case edit mode).

    2. Using HTML coding as explained in the blog below.

    Hiding the Fields Dynamically

    3. This method is something I read sometime back on SCN itself by one of the legends of Web UI Andrei Vishnevsky - SCN Member of the Month May 2012 and then on checking the code I also think that this can be useful if given a shot.

    The approach is to explore the method GET_CONFIG_DATA in view controller.

    Thanks,

    Ravi Katyal

    Add comment
    10|10000 characters needed characters exceeded

    • Hey Ravi,

      thanks for your quick reply.

      Option 2 and 3 look pretty much the same to me but I´m not too happy with that.

      I think we should give Option 1 a shot, as it is straight forward and seems to be an official solution.

      Should be satisfiying as long as the number of different fields to be shown/hidden in different scenarios doesn`t escallate.

      Thanks again &

      Best regards!