Skip to Content
avatar image
Former Member

how to bind data to sap.m.table..please give one example

sap.m.table data binding example

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Dec 15, 2016 at 12:05 PM
    <Table id="idProductsTable"         
    items="{ path: '/ProductCollection'}">
            <columns>
                <Column>
                    <Text text="Supplier" />
                </Column>          
            </columns>
            <items>
                <ColumnListItem>
                    <cells>
                        <Text
                            text="{SupplierName}" />
                    </cells>
                </ColumnListItem>
            </items>
        </Table>
    
    Add comment
    10|10000 characters needed characters exceeded

  • Dec 15, 2016 at 02:06 PM

    In Controller

    onInit: function() {
    var ojsonModel = new sap.ui.model.json.JSONModel("model/tableData.json");
    sap.ui.getCore().setModel(ojsonModel,"ojsonModel");
    }

    in View

    <Table rows="{ojsonModel>/tableDetails}" title="Display Data into the Table using JSON Model"
    selectionMode="MultiToggle" visibleRowCount="4" enableGrouping="true" threshold="2">
    <columns>
    <Column width="5rem">
    <m:Label text="Emp Id" />
    <template>
    <m:Text text="{ojsonModel>assID}" />
    </template>
    </Column>
    <Column width="4rem">
    <m:Label text="Emp Name" />
    <template>
    <m:Input value="{ojsonModel>Name}" />
    </template>
    </Column>
    <Column width="5rem">
    <m:Label text="company Name" />
    <template>
    <m:Text text="{ojsonModel>companyName}" />
    </template>
    </Column>
    </columns>
    </Table>

    JSON Model:

    {
    "tableDetails": [{
    "assID": "482004",
    "Name": "Vijay Kalluri",
    "Age": "30",
    "companyName": "Cognizant Technology Solutions",
    "salaryInfo": "1000"
    }, {
    "assID": "482005",
    "Name": "Venkata Ram",
    "Age": "30",
    "companyName": "Cognizant Technology Solutions",
    "salaryInfo": "1000"
    }, {
    "assID": "482006",
    "Name": "Jyothia",
    "Age": "30",
    "companyName": "Cognizant Technology Solutions",
    "salaryInfo": "1000"
    }

    ]
    }

    Add comment
    10|10000 characters needed characters exceeded