Skip to Content

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

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jan 24 at 09:27 AM

    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>
    
    Add comment
    10|10000 characters needed characters exceeded

  • Jan 24 at 07:12 AM

    Hi,

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

    Add comment
    10|10000 characters needed characters exceeded