user2644620
user2644620

Reputation: 199

How to remove value from the UI without removing it from model

Im facing a small issue in sap.m.Table. I want to remove a value in the column. But the value should not get removed from the model..

enter image description here

From the above image.. I want to remove the Unathorized absence from the table. But that value must be available in the model. For that I'm using below code...

this.getView().byId("idProductsTable").getItems()[2].getCells()[3].setProperty("text", "");

From the above code.. value is getting removed from both model and table. But my requirement is like value should be removed only from the Table.

This is what is happening with the above piece of code. Value is getting removed both from model and table. enter image description here

If I remove the value from the table, it should get removed from the table but not from the model.

Upvotes: 1

Views: 196

Answers (1)

Boghyon Hoffmann
Boghyon Hoffmann

Reputation: 18064

Use the property visible in the Text control, for example, with an expression binding:

<ColumnListItem>
  <cells>
    <!-- ... -->
    <Text
      visible="{= ${myModel>LeaveType} !== 'Unauthorized absence'}"
      text="{myModel>LeaveType}"
    />
  </cells>
</ColumnListItem>

The text will be then "removed" but only from the UI. In the DOM, the text element gets the CSS property display: none which doesn't occupy any spaces in contrast to visibility: hidden.


Note: The above code snippet is just a short example to give you an idea. Do not compare text values to hard coded string literals that might be translated or easily changed. Adjust the code according to your project.

Upvotes: 1

Related Questions