Skip to Content

Access custom field in sap.m.table with odata base

Mar 07 at 01:13 PM


avatar image

Hey everyone,

I'm facing a problem working with a table in SAP UI5. Most of the data shown is received by odata. But we require some input fields for further processing.

Adding them is pretty easy but I have no clue how to access them later. For example I have to filter whether the fields are filled or not.

Usually i would head for a filter on the model, but the model only contains data of the odata service.

Any ideas?

Thank you in advance.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Iftah Peretz
Mar 07 at 02:11 PM


Have you looked here? If this does not suffice please add you code and all the data needed or better yet a working example like here .

Show 2 Share
10 |10000 characters needed characters left characters exceeded
<m:Table id="productsTable" items="{/Basket}">
	<m:Column id="productCol" width="auto"><m:Text text="Materialnummer"/></m:Column>
	<m:Column id="zdarCol" width="auto" hAlign="End"><m:Text text="Dauerrabatt"/></m:Column>
	<m:Column id="mengCol" width="auto" hAlign="End"><m:Text text="Menge"/></m:Column>
		<m:ObjectIdentifier id="product" text="{MATNR}" class="sapMTableContentMargin"/>
			<l:VerticalLayout id="text">
				<m:Text text="{MAKTX}"/>
				<m:Text text="{GRTXT}"/>
		<m:Text id="zdar" text="{ZDAR}"/>
		<m:Input id="meng" liveChange="onMengChange" />

Just a small example. "Basket" is a one-way odata service.

Now I want to add a button in a header toolbar, which is filtering the output (when "meng" is filled, keep it, else hide).

How can i filter the table when meng is not part of the model?

I hope you get my point.

Best wishes,



What does getItems() returns? (see also here).

Francesco Alborghetti Mar 07 at 04:08 PM


I have a JSFiddle that does something similar, in liveChange handler i check the value and apply the filter on model.

In your case, you can create a button handler and with a cycle of items aggregation of your table and check the value of the input cell.

handleLiveChange: function (event) {
    if (event.getParameter("newValue") !== "filter") return;
    var oRow = event.getSource().getParent();
    var filterValue = oRow.getCells()[0].getText();
    if (filterValue) {
      var oFilter = new sap.ui.model.Filter("CustomerID", sap.ui.model.FilterOperator.NE, filterValue);
      var oTable = this.getView().byId("testTable");
      var item = oTable.getItems()[0];
      var oItemTemplate = item.clone();
      oTable.bindAggregation("items", {path:"/Customers", template:oItemTemplate, filters:[oFilter]});
10 |10000 characters needed characters left characters exceeded