Skip to Content
avatar image
Former Member

SAPUI5: Hiding a <List> via setVisibility not working

I have an xml view with a sap.m.List that holds some sap.m.InputListItems:

<List id="listJobParams">  


  <headerToolbar> ... </headerToolbar>


  <InputListItem label="Partition" id="listItemPartition" visible="false">

    <Select id="partition" selectedKey="{/partition}" />

  </InputListItem>


  ...

</List>

Based on certain conditions, I want to either hide the the entire List or only certain InputListItems, using the setVisibility(true|false) method.

Hiding/showing input list items based on a condition works fine, but hiding/showing the entire list does not work.

The problem: once the list has been hidden via this.byId("listJobParams").setVisibility(false), it is not possible to show the list again using this.byId("listJobParams").setVisibility(true);

There is no error in the js console, but also the list does not show up. So I wonder why the InputListItem behave differently than the List.

Controller code (called from within onInit() method):

_refreshJobDetailInput : function (channelId, eventId, data) {

  // hiding/showing input list item

  this.byId("listItemPartition").setVisible(data.jobType=='singlePartitionIndexingJob');

   

  // hiding/showing the entire list DOES NOT WORK; once hidden, it will never appear again, even though the condition is true (and logs as true in the console)

  this.byId("listJobParams").setVisible(data.jobType=='singlePartitionIndexingJob');

},


The method is available and documented for `sap.m.list`'s parent class (https://openui5.hana.ondemand.com/docs/api/symbols/sap.m.ListBase.html#setVisible)

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    May 01, 2014 at 05:29 PM

    Hi Mathias,

    yeah, i have seen these kinda issues at time. Once you do the list.setVisibile(true), manually rerender the list or page in the next line, either list.rerender() or page.rerender() . This is the workaround for the issue.

    Regards

    Sakthivel

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      It looks like a defect. I recommend putting it up on jsbin & submitting a bug report.

      An alternate workaround is to hook the onAfterRendering event & use jQuery .css("display", "none") to hide or show the DOM element. SAPUI5 "visible : true" means "in the DOM" and "visible : false" means the DOM element is removed or simply not created.