Problem:
How to bind the array/list data to the grid column?
Meeting Class Structure:
string ID
string Meeting
List<Note> Notes
Note Class Structure
string ID
string Descrip
string EnteredBy
string EnteredDate
I want to display all the Descrip's from the Notes list in a grid column something like below:
Hi Cliff,
Thanks for contacting Syncfusion support.
We have achieved your requirement using “Template” property of the Grid columns and refer to the below code example.
|
<script type="text/x-jsrender" id ="template"> {{for Addresses}} <span>{{>Address1}}</span> <span>{{>Address2}}</span><br /> {{/for}} </script>
<asp:ScriptManager runat="server"></asp:ScriptManager> <div> <ej:Grid ID="Grid" runat="server" > <Columns> <ej:Column Field="ID" HeaderText="ID" IsPrimaryKey="true" Visible="false" > </ej:Column> <ej:Column Field="FirstName" HeaderText="First Name" > </ej:Column> <ej:Column Field="LastName" HeaderText="Last Name" > </ej:Column> <ej:Column HeaderText="Address" Template=true TemplateID="#template"> </ej:Column> </Columns> </ej:Grid> |
We have created a sample that you can download from the below link.
http://www.syncfusion.com/downloads/support/forum/121555/ze/TestGrid497971258
Regards,
Saravanan A.
Hi Cliff,
Thanks for your update.
We are happy that the provided information helped you.
Regards,
Saravanan A.
|
<script type="text/x-template" id ="template">
${for(item of Name)}
<span>FirstName:${item.FirstName}</span> &<span>LastName:${item.LastName}</span> <br>
${/for}
</script>
<body>
<div id="Grid"></div>
<script>
var grid = new ej.grids.Grid({
dataSource: complexData,
columns: [
{ field: 'EmployeeID', headerText: 'ID', width: 120 },
{ headerText: 'Name', template: '#template' },
{ field: 'Title', headerText: 'Title' }
],
width:600
});
grid.appendTo('#Grid');
</script>
</body> |