简体   繁体   English

sapui5- 如何更改面板图标单击事件的默认操作?

[英]sapui5- How to change default action on panel icon click event?

I am using sapui5 panel, and I allow to expandable that it will show default icon on toolbar ">", when I click on it, it will togglecollapse, but I want to add some action on it.我正在使用 sapui5 面板,我允许扩展它会在工具栏“>”上显示默认图标,当我点击它时,它会切换折叠,但我想在它上面添加一些操作。

Here is the panel and there is one icon at the end.这是面板,最后有一个图标。 Any idea to override function, customize function, or add some action on that icon when we click on it?当我们点击它时,有什么想法可以覆盖功能、自定义功能或在该图标上添加一些操作吗?

My purpose is, I want to add warning message before panel is collapsed, if I click "yes" to confirm, it can collapse, "No" it still the same, do nothing.我的目的是,我想在面板折叠之前添加警告信息,如果我点击“是”确认,它可以折叠,“否”它仍然一样,什么都不做。

这是面板和图标的图像

Have you tried attachExpand ?你试过attachExpand吗? https://sapui5.hana.ondemand.com/docs/api/symbols/sap.m.Panel.html#attachExpand https://sapui5.hana.ondemand.com/docs/api/symbols/sap.m.Panel.html#attachExpand

I'm still new to this ui5 :p我还是这个 ui5 的新手:p

Here we go我们走

        var panel = new sap.m.Panel("panel-1", {
            headerText:"Test Panel",
            expandable: true
        });
        panel.setExpanded = function (bExpanded) {
            if (bExpanded === this.getExpanded()) {
                return this;
            }
            //may need to reset this later
            this.setProperty("expanded", bExpanded, true);
            if (!this.getExpandable()) {
                return this;
            }

            //add custom logic here
            if(bExpanded){

            }
            //custom logic

            this._getIcon().$().attr("aria-expanded", this.getExpanded());
            this._toggleExpandCollapse();
            this._toggleCssClasses();

            this.fireExpand({ expand : bExpanded });
            return this;
        };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM