片段没有得到正确的控制器 [英] Fragment not get correct Controller

查看:38
本文介绍了片段没有得到正确的控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在控制器 formAddElement 中通过此代码实例化了一个片段.(我使用 this 来传递当前控制器)

I istantiate a fragment by this code in the controller formAddElement. (i use this to pass current controller)

this._oDialog = sap.ui.xmlfragment("apps.appIntra.fragment.dialogClienti",this);

在同一个控制器中,我有一个函数 handleSearch

In the same controller i have a function handleSearch

handleSearch: function(oEvent) {
        var sValue = oEvent.getParameter("value");
        var oFilter = new sap.ui.model.Filter("RAG_SOC_1", sap.ui.model.FilterOperator.Contains, sValue);
        var oBinding = oEvent.getSource().getBinding("items");
        oBinding.filter([oFilter]);
  },

当我在片段中按下搜索时,控制器中的功能不会触发.

when in the fragment i press search the function in the controller not fire.

但是如果我使用

this._oDialog = sap.ui.xmlfragment("apps.appIntra.fragment.dialogClienti", sap.ui.getCore().byId('formAddElement').getController());

一切顺利!!为什么???O_o

all work!! WHY??? O_o

推荐答案

this"应该可以工作.您需要在 chrome 中运行 F12 调试器来检查this"是什么,是否是 oController 对象.它可能是其他对象,具体取决于调用对象.

"this" should work. you need to run F12 debugger in chrome to check what "this" is, whether it is the oController object. it could be other object depending the calling object.

这篇关于片段没有得到正确的控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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