【发布时间】:2014-06-18 03:00:36
【问题描述】:
我有一个带有 sap.m.List 的 xml 视图,其中包含一些 sap.m.InputListItems:
<List id="listJobParams">
<headerToolbar> ... </headerToolbar>
<InputListItem label="Partition" id="listItemPartition" visible="false">
<Select id="partition" selectedKey="{/partition}" />
</InputListItem>
...
</List>
基于某些条件,我想使用setVisibility(true|false) 方法隐藏整个列表或仅隐藏某些 InputListItems。
根据条件隐藏/显示输入列表项可以正常工作,但隐藏/显示整个列表不起作用。
问题:通过this.byId("listJobParams").setVisibility(false)隐藏列表后,使用this.byId("listJobParams").setVisibility(true)无法再次显示列表;
js控制台没有报错,但是列表也没有显示出来。所以我想知道为什么 InputListItem 的行为与 List 不同。
控制器代码(从onInit() 方法中调用):
_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');
}
该方法可用于sap.m.list 的父类(https://openui5.hana.ondemand.com/docs/api/symbols/sap.m.ListBase.html#setVisible)并记录在案
更新:
根据下面 Qualiture 的回答,我尝试了以下无效和/或重新渲染的组合,但到目前为止没有帮助。
// 2 parents up is the 'panel'
this.byId("listJobParams").getParent().getParent().invalidate();
this.byId("listJobParams").getParent().getParent().rerender();
// 3 parents up is the 'page'
this.byId("listJobParams").getParent().getParent().getParent().invalidate();
this.byId("listJobParams").getParent().getParent().getParent().rerender();
// 4 parents up is the 'xmlview'
this.byId("listJobParams").getParent().getParent().getParent().getParent().invalidate();
this.byId("listJobParams").getParent().getParent().getParent().getParent().rerender();
// this return the shell
this.byId("listJobParams").getParent().getParent().getParent().getParent().getParent().getParent().getParent().invalidate();
this.byId("listJobParams").getParent().getParent().getParent().getParent().getParent().getParent().getParent().rerender();
【问题讨论】:
标签: listview visibility sapui5