从sapui5中的印刷机处理程序内部调用控制器功能 [英] Calling Controller Function from inside a press handler in sapui5

查看:85
本文介绍了从sapui5中的印刷机处理程序内部调用控制器功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在ButtonPress上过滤一个表,可以看到Table + 3其他按钮。我希望在控制器中执行此操作,但我似乎无法找到在事件处理程序中调用控制器函数的方法。

I want to filter a table on ButtonPress an set the Table + 3 other buttons visible. My wish is to do that in the controller, but I cant seem to find a way to call a Controller Function inside the event Handler.

按钮:

var searchButton = new sap.ui.commons.Button({
            text: 'Partner suchen',
            width: "100%",
            press: function(oEvent) {
                var myInput = sap.ui.getCore().byId('Handler').getValue(); //$('.row input[role="textbox"]:enabled').val();
                var query = oEvent.getParameter("query");

                var listBinding = oTable2.getBinding();
                var oFilter = new sap.ui.model.Filter ("nummer", sap.ui.model.FilterOperator.EQ, myInput);
                listBinding.filter([oFilter]);

                //[oController.enablen, oController]

                //sap.ui.getCore().byId('vertL2').setVisible(true);
                //sap.ui.getCore().byId(this.createId('anlegBut')).setEnabled(true);
                //sap.ui.getCore().byId(this.createId('editBut')).setEnabled(true);
                //sap.ui.getCore().byId(this.createId('submitBut')).setEnabled(true);
            }
        });

在我的控制器中,我有这个功能,我想打电话:

In my controller I have this function that I want to call:

enablen : function () {
    var view = this.getView();

    sap.ui.getCore().byId('vertL2').setVisible(true);
    view.byId('anlegBut').setEnabled(true);
    view.byId('editBut').setEnabled(true);
    view.byId('submitBut').setEnabled(true);
}

但是在Button的事件处理程序中调用它似乎是不可能的。

But calling it inside the Event Handler of the Button seems not possible.

推荐答案

解决方法是(在再次查看API之后):

The solution to this was (after looking at the API again):

var searchButton = new sap.ui.commons.Button({
            text: 'Partner suchen',
            width: "100%",
            press: /*[oController.enablen, oController]*/ [function(oEvent) {
                var myInput = sap.ui.getCore().byId('Handler').getValue(); //$('.row input[role="textbox"]:enabled').val();
                var query = oEvent.getParameter("query");

                var listBinding = oTable2.getBinding();
                var oFilter = new sap.ui.model.Filter ("nummer", sap.ui.model.FilterOperator.EQ, myInput);
                listBinding.filter([oFilter]);

                this.enablen();

            }, oController]
});

这篇关于从sapui5中的印刷机处理程序内部调用控制器功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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