在TreeTable绑定上添加动态过滤器

时间:2017-03-19 19:34:35

标签: data-binding sapui5 sap-fiori

我想传递一个名为' app'从我的Fiori磁贴配置到我的应用程序并在数据绑定中使用它。我在xml视图中无法进行动态过滤,this question建议使用 attachAfterRendering 功能。我在视图控制器中尝试了以下代码,但结果不一致,有时数据加载正确,有时我得到“无数据”#。任何帮助将不胜感激。

    onInit: function() {

        var oStartupParameters = this.getMyComponent().getComponentData().startupParameters;

        this._oView = this.getView();
        this._oView.attachAfterRendering(function() {
            var oTreeTable = this.byId("treeTable");
            oTreeTable.bindAggregation("rows", {
                path: "/Nodes",
                filters: [
                    new sap.ui.model.Filter("Application", sap.ui.model.FilterOperator.EQ, oStartupParameters["app"])
                ]
            });
        });
    }

1 个答案:

答案 0 :(得分:1)

您提到的帖子是关于在XML视图的Filter定义中使用动态绑定表达式。根据我的理解,它与你的情况不同。

不使用attachAfterRendering,您可以在检索到oStartupParameters后在onInit函数中的绑定信息中定义过滤器。请检查example。谢谢。

var oTreeTable = this.byId("treeTable");
oTreeTable.bindRows({ path: "/Nodes", filters: [
                new sap.ui.model.Filter("Application", sap.ui.model.FilterOperator.EQ, oStartupParameters["app"])
            ]});