Skip to Content

How to get column binding in JavaScript


I try to get the binding information of columns of a sap.m.table in JavaScript but I can´t figure out how to do that.

This is my table definition (shortened example):

<Table id="tblSystemSelection" inset="false" items="{/Systems}" mode="SingleSelectMaster" width="auto">
  <Label text="Column A"/>
  <Label text="Column B"/>
  <Text text="{MyColumnA}"/>
  <Text text="{MyColumnB}"/>

Now, in JavaScript I would like to get the binding paths "MyColumnA" and "MyColumnB".

I can get the table object and the binding info for the "items" collection:

var oTable = sap.ui.getCore().byId("tblSystemSelection");
var oItemsBinding = oTable.getBinding("items");

I can also get the cells of the item template:


But nowhere I can find the binding path information "MyColumnA" and "MyColumnB".

Does anyone know how to get them?

Thanks and best regards,


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 15, 2015 at 03:30 PM

    You can try something like this.

    var aBindingInfos = oTable.getBindingInfo('items').template.getCells().map(function(oCell){
         return oCell.getBindingInfo('text').parts[0].path;
    console.log(aBindingInfos) // ["MyColumnA","MyColumnB"]
    Add comment
    10|10000 characters needed characters exceeded

  • Oct 15, 2015 at 12:54 PM

    Hi Sebastian,

    I could see in your xml view that you haven't done any columns binding with model. They are hard-coded as "Column A" and "Column B" for text property using label control. If you just wanted to get hold of the columns, you can just say like this -

    var oTable = this.getView().byId("yourTableID");               //Your Table ID
    oTable.getColumns();          //This will fetch you the columns array and you can do [0] [1] ....... to get hold of specific column

    If you're looking on something about the columns binding and retrieving them using the method oTable.getBinding("columns"), then will this JSBin help? JS Bin - Collaborative JavaScript Debugging

    Click on the Columns Binding button, you will get the binding path and the model associated with that path as alert. Please correct if my understanding is wrong with regard to your requirement.


    Sai Vellanki.

    Add comment
    10|10000 characters needed characters exceeded