Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to get column binding in JavaScript

Hi,

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">

  <columns>

  <Column>

  <Label text="Column A"/>

  </Column>

  <Column>

  <Label text="Column B"/>

  </Column>

  </columns>

  <items>

  <ColumnListItem>

  <Text text="{MyColumnA}"/>

  <Text text="{MyColumnB}"/>

  </ColumnListItem>

  </items>

</Table>

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:

oBindingInfo.template.getCells()

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

Does anyone know how to get them?

Thanks and best regards,

Sebastian

Tags:
Former Member
Former Member replied

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"]

1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question