Skip to Content
0

how to add new listitems to my table in xml view??

Jan 23 at 01:47 PM

81

avatar image

Hi All,

i am using XML view containing Table ,where i need add a line Item by clicking button.

how can i achieve this??

my view code.

<items> <ColumnListItem> <cells > <Input id="sno" value="1" enabled="false" /> <ComboBox id="item" items="{/results}" width="auto"> <items> <core:Item text="{Maktg}" /> </items> </ComboBox> <Input id="qty" type="Number" value="0" enabled="false" /> <Button type="Accept" press="increment" icon="sap-icon://sys-add" width="1px"/> <Button type="Reject" press="decrement" icon="sap-icon://sys-minus" width="1px"/> </cells> </ColumnListItem>

view.png (8.1 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Efim Parshin Jan 24 at 09:27 AM
0

If your table binded with aggregation binding, you can manipulate its items through the model. For Example:

onAddLineItemPress: function(oEvent) {
    this.oMyModel.getProperty('/lineitems').push({});
    this.oMyModel.updateBindings();
}
<Button press="onAddLineItemPress" text="Add line item" />
<Table items="{/lineItems}">
    <columns>...</columns>
    <items>
        <ColumnListItem>
            <cells >
                <Input id="sno" value="1" enabled="false" />
                <ComboBox id="item" items="{/results}" width="auto">
                    <items>
                        <core:Item text="{Maktg}" />
                    </items>
                </ComboBox>
                <Input id="qty" type="Number" value="0" enabled="false" />
                <Button type="Accept" press="increment" icon="sap-icon://sys-add" width="1px"/>
                <Button type="Reject" press="decrement" icon="sap-icon://sys-minus" width="1px"/>
            </cells>
        </ColumnListItem>
    <items>
</Table>
Show 3 Share
10 |10000 characters needed characters left characters exceeded

Here In Table I am not using any Binding Just Simply Declaring my feilds..

<form:content>
<Table id="itemTable" title="Menu List"  width="auto"  >
<columns>
<Column width="auto">
<Label id="no" text="SNo."   />

</Column>
<Column width="auto">
<Label text="Description" />
</Column>
<Column width="auto">
<Label text="Qty" />
</Column>
<Column width="auto">
<Label text="Add Qty" />
</Column>
<Column width="auto">
<Label text="Sub Qty" />
</Column>
</columns>
0
surya prakash tanguturi

Then you can use addItem method of sap.m.Table:

var oTable = this.byId('itemTable');
var oItem = new sap.m.ColumnListItem({
    cells: [
        //manualy create control for each column
    ]
});
oTable.addItem(oItem);
1

yeah Its Worked.Thanks Alot

0
Irfan Gokak Jan 24 at 07:12 AM
0

Hi,

Please show me how you're displaying these 2 lines. share your model code.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Declaring fields in Normal xml mode not using Model.

0