Skip to Content
author's profile photo Former Member
Former Member

getBindingInfo - how to avoid it?

Hi guys,

I have an app with an XML view and controller.

What I need to do basically is to put a table on the view, and items with binding - however the binding filter should be dynamic.

So right now I'm having a workaround, which I have a feeling is not so great.

Is there a better way to do this than what I did?

In the controller, I can't get the table's binding, but only the binding info which I think is not recommended to use.

What I also want to avoid is to first load the data without the filter, and then put the filter.

This is what the XML view looks like:

...

<Table

id="table"

items="{

path: '/Rules',

filters: [],

sorter: {

path: 'Name',

descending: false

}

}"

growing="true"

growingScrollToLoad="true"

updateFinished="onUpdateFinished">

...

and the controller:

...

onInit : function () {

oTable = this.byId("table");

var appId = "Something not static";

var oBinding = oTable.getBindingInfo("items");

oBinding.filters = [new sap.ui.model.Filter("ApplicationId", "EQ", appId)];

...

Thanks,

Or.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Aug 15, 2016 at 04:00 PM

    Why don't you move the items declaration from the view to the controller?

    Regards,

    Jamie

    SAP - Technology RIG

    Add a comment
    10|10000 characters needed characters exceeded

    • You can use a fragment to declare the table and then use it for the template.

      var oTblFrag = new sap.ui.xmlfragment("com.sap.demo.view.Table", this);
      
        this._oList.bindAggregation("items", {
         path: "/Collection",
         template: oTblFrag,
         filters: myFilters
        });
      

      Regards,

      Jamie

      SAP - Technology RIG

  • author's profile photo Former Member
    Former Member
    Posted on Aug 15, 2016 at 04:36 PM

    Hi,

    You can do this, SAPUI5 Explored

    there dynamic filter used, check the handleConfirm function in Controller file, Dialog.fragment.xml is for the filter,sorter Pop-up(do check this too)

    One more thing, "In the controller, I can't get the table's binding" Why?

    if you are able to get the table control, I think you should get its binding too.

    Thanks,

    Chandan

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      So a filter is predefined and on that data you want dynamic filter?

      So if the Model is Odata, at onInit() read the model with your filter, then use the dynamic filter in a different function(as in my 1st reply).

      Like this- inside onInit() do something like this-

      oModel.read("/your_dataset",

      null,

      ["$filter=your_entity eq 'value'"], // filter it

      false,

      function(oData, oResponse){

      //oData will contain filtered data, bind it with the table

      }

      );

      Now make use of SAPUI5 explored example filter in your own function.

      This should do your job.

      Thanks,

      chandan

  • Posted on Aug 15, 2016 at 04:42 PM

    Or

    you can declare the end point in the table (view) then on the controller event ... onBeforeRendering you can apply the filter you need (dynamically)

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.