Skip to Content
author's profile photo Former Member
Former Member

display columns and data dynamically from odata into sap.m.table

Hi,

Please share any sample code to display columns and data dynamically from odata/JSon into sap.m.table. Please share recommended ways to achieve dynamic column names as well into sap.m.table

Regards,

Koti Reddy

Add comment
10|10000 characters needed characters exceeded

2 Answers

  • Best Answer
    Posted on Jan 06, 2015 at 08:05 AM

    Hi Koti,

    Refer this thread sapui5 - Dynamic binding of table column and rows - Stack Overflow and example provided into it.

    you can find working example at JS Bin - Collaborative JavaScript Debugging</title> <link rel="alternate" type="application/jso…

    This example is based on sap.ui.table but you can easily code one for sap.m.table

    Regards,

    Chandra

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2015 at 04:57 AM

    Tried like below.

    XML View :

    <Table id="tbl" inset="true" multiSelect="true" selectionMode="MultiToggle" mode="MultiSelect"

    items="{ path: '/EntitySet'}">

    <columns>

    </columns>

    <items>

    <ColumnListItem>

    </ColumnListItem>

    </items>

    </Table>

    Controller : I used odatamodel reading to display data.

    var sTemplate = new sap.m.ColumnListItem();

    var oTable = sap.ui.getCore().byId("viewid").byId("tbl");

    addColumns(oTable, param1,param2, sTemplate);

    sap.ui.getCore().byId("view id").byId("tbl").bindItems({

    path : "/EntitySet",

    template : sTemplate,

    filters : filters}

    In addColumns , I read entityset model to display column properties and display.

    Regards,

    Koti Reddy

    Add comment
    10|10000 characters needed characters exceeded