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

SAPUI5 getBinding() returns undefined

Hello,

I'm an abap developer, but now i'm trying to build a simple application in SAPUI5 and I'm stuck with a Problem. I think the solution is quiet simple, but I can't figure it out.

I built the application using webIDE and a simple oData Service that provides me with data to fill a sap.m.table in a XML view. works quiet good.

But now I'm trying to set a filter on the data in the the table. In my view Controller I have the following code, first line works, I get a reference to my table, but the getBinding() method just Returns undefined and I can't figure out why.

Thanks in advance for your help.

regards Alex

var oTable = this.getView().byId("__table0");  
var oTableBinding = oTable.getBinding("items");
var filters = [];  filters.push(new sap.ui.model.Filter("ProjectNo", "EQ", "999"));
oTableBinding.filter([filters]);

Add comment
10|10000 characters needed characters exceeded

  • Former Member

    Do you really have the tableId defined this way ("__table0")? It looks like the auto generated ID. Can you please share your view as well?

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 14, 2017 at 05:05 PM

    After some further reading and try outs I used another way and now I am using the bindAggregation method, which also allows filtering.

    Thanks to all who tried to help me to solve my problem.

    kind regards

    ALex

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      I am also facing the same problem so can you please share your code with me, as i am not able to use bindAggregation method.

      Thanks in advance for your help.

      Regards,

      Anshu

  • Posted on Feb 07, 2017 at 08:26 PM

    I think you are trying to access the binding information of the table in onInit method before the data is loaded. If so check this link

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 07, 2017 at 10:37 AM

    yep, that is the id generated by webIDE. In my XML view I just bind the data via items="":

    that is the table Definition in my view.xml:


    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Please try adding an id (ex: "myTable") to your table control and access it.

      You could accessing it like

      this.getView().byId("myTable");   

      or

      this.byId("myTable");