1

I want to pass a parameter called 'app' from my Fiori tile configuration to my app and use it in the data binding. I gather dynamic filtering is not possible on the xml view and this question has a suggestion is to use the attachAfterRendering function. I've tried the following code in my view controller but the results are inconsistent, sometimes the data loads correctly, other times I get 'No data'. Any help would be greatly appreciated.

    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"])
                ]
            });
        });
    }
Community
  • 1
  • 1
user2823030
  • 109
  • 2
  • 6

1 Answers1

1

The posts you mentioned is about using dynamic binding expression in a Filter definition in a XML view. From my understanding, it is not the same case as yours.

NOT using attachAfterRendering, you can simply define a Filter in the binding info in your onInit function after the oStartupParameters is retrieved . Please check this example. Thank you.

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