cancel
Showing results for 
Search instead for 
Did you mean: 

Add/Delete items in sap.m.table using buttons action - table is created using oData binding

pradeepsrawat
Explorer
0 Kudos

Dear Experts,

I want to achieve adding and deleting items in sap.m.table using buttons.

My view is XML view created using oData binding with multilevel navigation and Table is created using oData navigation binding at 3rd level.

oData is like - HeaderSet --> TabSet --> TableSet

I tried may thing but nothing is working.

1. I am unable to read my table data items this.getView().byId("TableID").getItems() - does not return anything.

2. I tried using createEntity for oData model as well but its not adding new rows.

Please help me find a good solution to achieve this requirement-

My requirement is to have multiple Tabs dynamically based on oData and inside each Tab a Table control where I can add and delete new items with exixting oData items.

Below is my XML View

<IconTabBar id="idDisplayTab"

selectedKey="{/NavHeadToBuckets/BucketId}"

items="{path: 'NavHeadToBuckets }">

<items>

<IconTabFilter key="{BucketId}"

<Table id="idBucketItems" inset="true" mode="MultiSelect" selectionChange="onItemSelect" items="{path: 'NavBucketToItems}">

<headerToolbar>

<OverflowToolbar id="otb3">

<Button id="idAddBucketItems" icon="sap-icon://add" press="_onAddItem" type="Emphasized" />

<Button id="idDeleteBucketItems" icon="sap-icon://delete" press="onDeleteItems" type="Emphasized" class="deleteButton" />

</OverflowToolbar>

</headerToolbar>

<columns>

<Column id="test1"> <Text text="{i18n>Test1}" /> </Column>

<Column id="test2" demandPopin="true"> <Text text="{i18n>Test2}" /> </Column>

</columns>

<items>

<ColumnListItem>

<cells> <Text text="{test1}" />

<Text text="{test2}" /> </cells>

</ColumnListItem>

</items>

</Table>

</IconTabFilter>

</items>

</IconTabBar>

Accepted Solutions (0)

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos

you won't be able to do it with odatamodel binding regarding adding new row without saving first.

pradeepsrawat
Explorer
0 Kudos

Then what is the best way to achieve my requirement - for adding multiple tabs dynamically - under each tab a table - and option to add/delete rows from table. I have already created oData with multi level navigation for this - . I am able to generate the UI, however, I am unable to add and delete rows from table UI.