Skip to Content
2
Former Member
Apr 02, 2014 at 10:10 AM

SAPUI5: Table: how to bind a list into a cell of a Table?

1687 Views

Hi there,

I have a json model with the following data:

myData={Persons:[

{

Name: "David",

Age: "29",

Kids: [{kName:"Kim1"},{kName:"Tom1"}]

},

{

Name: "Anne",

Age: "27",

Kids: [{kName:"Kim2"},{kName:"Tom2"}]

}

]

};

Now in the View, I use a Table which shows the Name and Age in the 1st and 2nd columns (these work fine). The 3rd column should show the Kids which is a "list" of the names. So I expect UI look like this:

Name Age Kids

David 29 Kim1

Tom1

Anne 27 Kim2

Tom2

Here is the code of "View":

var oTable = new sap.ui.table.Table("WorkOrderTable",{...});

oTable.addColumn(new sap.ui.table.Column({

label: new sap.ui.commons.Label({text: "Kids"}),

template:

new sap.ui.commons.ListBox({

minWidth : "60px",

visibleItems : 2,

items:{

path: "/Persons/Kids",

template: new sap.ui.core.ListItem({text:"{kName}"}),

},

}),

resizable:false,

width: "15%"

}));

oTable.bindRows("/Persons");


The code above just shows a blank square instead of the list in the cells of the 3rd column. I don't know if my data model is not right, or the table binding has problem.

Anyone has an idea what is wrong? Thanks very much!

Dong Zhu