SAPUI5面板崩溃事件

时间:2014-03-18 09:19:45

标签: javascript sapui5

我正在开发的这个SAPUI5应用程序使用Panel控件,其上有一些按钮。现在,每当用户折叠面板并在展开时显示它们时,我都必须隐藏这些按钮。我尝试使用getCollapsed()方法,但没有效果。我基本上寻找的是面板的collapse事件,默认情况下不可用。

有任何帮助吗?

感谢。

3 个答案:

答案 0 :(得分:1)

嗯,看起来Panel控件确实没有事件处理程序......

作为一种解决方法,您可以在面板托盘中添加自己的展开/折叠切换按钮,单击该按钮可以获取getCollapsed()状态并相应地显示/隐藏其他按钮

答案 1 :(得分:1)

这里唯一的解决方案可能是使用您自己的按钮替换默认折叠图标,并将press事件附加到其上。像:

1. Declare a `Panel` with `showCollapseIcon` set to false.

    var oPanel = new sap.ui.commons.Panel({                    
        showCollapseIcon: false
    });
2. Add your own button. I prefer a `lite` button.

    var oCollapseButton = new sap.ui.commons.Button({
        icon: '<your icon>',
        lite: true,
        press: function (e) {            
            if (!oPanel.getCollapsed()) {
                //If not collapsed
                oPanel.setCollapsed(true);
                //Code to hide panel buttons
                //(and toggle collapse button image if needed) after this
            } else {
                //If already collapsed
                oPanel.setCollapsed(false);
                //Code to show panel buttons
                //(and toggle collapse button image if needed) after this
            }
        }
    });    
    oPanel.addButton(oCollapseButton);

P.S:您可能还想为自定义折叠按钮添加一些样式和对齐方式。为此,您可以在按钮中添加CSS3类,然后将其添加到面板中,如:

    oCollapseButton.addStyleClass('<your class>');

答案 2 :(得分:0)

您可以使用sap.m.Panel https://openui5.hana.ondemand.com/docs/api/symbols/sap.m.Panel.html#event:expand

具有扩展属性,您只需使用

即可
setExpanded(true) ; 

展开面板,让控件保持其状态,而不必跟踪它。

我确信自从您提出问题后这一切都发生了变化,这个答案与1.24.2

有关
相关问题