SAPUI5 IconTabBar/IconTabFilter:触发图标选项卡选择 [英] SAPUI5 IconTabBar/IconTabFilter: Trigger Icon Tab Select

查看:18
本文介绍了SAPUI5 IconTabBar/IconTabFilter:触发图标选项卡选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 XML 视图,用于显示 IconTabBar.在用户选择这些IconTab"之一时,我想在控制器 js 文件中触发一个方法.

I have an XML view which I am using to display an IconTabBar. On the user selecting one of these "IconTab's" I would like to trigger a method in the controller js file.

对于 IconTab 定义之一,我有以下代码.

I have the following code for one of the IconTab definitions.

<IconTabFilter text="Data" icon="sap-icon://documents" press="onData">
    <content press="onData" id="data">
        <cmn:Tree nodes="{/aRoot}">
            <cmn:TreeNode text="{@name} TagNameHere?"></cmn:TreeNode>
        </cmn:Tree>
    </content>
</IconTabFilter>

我假设 press="onData" 将允许我触发控制器文件上的方法.没有.

I was assuming the press="onData" would allow me to trigger a method on the controller file. It does not.

有谁知道这是否可以完成,如果可以,如何做?

Does anyone know if this can be done and if so how?

谢谢

马丁

推荐答案

可以通过切换逻辑来使用父IconTabBarselect(oControlEvent)事件IconTabFilter

You can use the select(oControlEvent) event of the parent IconTabBar by switching the logic according to the key value of IconTabFilter

<script src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.m"></script>
<script id="view1" type="sapui5/xmlview">
    <mvc:View xmlns:l="sap.ui.layout" controllerName="test.controller" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:f="sap.ui.layout.form">

        <l:VerticalLayout>

            <IconTabBar select="onSelectChanged">
                <items>
                    <IconTabFilter key="1" text="Test1">
                        <Text text="Test1 " />
                    </IconTabFilter>
                    <IconTabFilter key="2" text="Test2">
                        <Text text="Test2 " />
                    </IconTabFilter>

                </items>
            </IconTabBar>
        </l:VerticalLayout>

    </mvc:View>

</script>
<script>
    sap.ui.controller("test.controller", {
        onSelectChanged: function(oEvent) {
            var key =oEvent.getParameters().key;
            if(key=='1') {
              alert("Click Test1");
            }
            else if(key == '2') 
            {
              alert("Click Test2") 
            };
        }

    });

    var oView = sap.ui.xmlview({
        viewContent: jQuery("#view1").html()
    });
    oView.placeAt("content");
</script>


<boy class="sapUiBody" id="content" />

这篇关于SAPUI5 IconTabBar/IconTabFilter:触发图标选项卡选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆