我想在SAPUI5的SmartFilterBar中选择第一个复选框后隐藏/显示一个复选框。它应该是属性的改变,但我无法弄清楚正确的代码。 这是SmartFilterBar里面的XML代码:
<smartFilterBar:ControlConfiguration key="checkbox1" label="{i18n>Processingwithoutdialog}" visibleInAdvancedArea="true" >
<smartFilterBar:customControl>
<CheckBox />
</smartFilterBar:customControl>
</smartFilterBar:ControlConfiguration>
<smartFilterBar:ControlConfiguration key="checkbox4" label="{i18n>Restrictedprotocol}" visibleInAdvancedArea="true">
<smartFilterBar:customControl>
<CheckBox editable="false" select="onSelect"/>
</smartFilterBar:customControl>
我在controller.js中的代码:
onSelect : function(oEvent) {
var oSmartTable = oEvent.getSource();
var oSmartFilterBar = this.byId("smartFilterBar");
if (oSmartFilterBar instanceof sap.ui.comp.smartfilterbar.SmartFilterBar) {
var oCustom = oSmartFilterBar.getControlByKey("checkbox1");
var oCustom2 = oSmartFilterBar.getControlByKey("checkbox4");
oCustom2.setEditable( !oCustom.getSelected() );
}
答案 0 :(得分:0)
不完全确定您要使用此功能实现的目标或调用它的功能,但我发现
存在问题var oCustom = oSmartFilterBar.getControlByKey("checkbox1").getChecked;
然后
oCustom.onchange = function() {
oCustom2.editable = this.checked ? false : true;
}
o自定义不是控件,但可能是函数调用缺少括号的结果。
所以我认为你需要从改变开始:
var oCustom = oSmartFilterBar.getControlByKey("checkbox1")
然后你可以询问控件的内容,例如:
oCustom2.setEditable( !oCustom.getSelected() );
如果在onSelect事件上调用了这个技巧,那么你就需要使用attachSelect附加函数,或者你可以在xml中设置select事件。