Skip to Content
0

SAPUI5 getBinding() returns undefined

Feb 07, 2017 at 10:08 AM

1.5k

avatar image
Former Member

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]);

10 |10000 characters needed characters left 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?

0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member Feb 14, 2017 at 05:05 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Srikanth KV Feb 07, 2017 at 08:26 PM
1

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

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 07, 2017 at 10:37 AM
0

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:


Show 1 Share
10 |10000 characters needed characters left 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");  
0