I am wondering if anyone could help with a problem I am having using the Infragistics ignite data grid. I am using the Infragistics.Web.Mvc .net library. The issue is that I have an array inside my list which is filling the grid. I want to be able to display each value in the array in a separate column. This works in my view for example.
@foreach (var item in Model) {
var firstname = item.BillToContact.FirstName;
var lastname = item.BillToContact.LastName;
foreach (var number in item.BillToContact.PhoneNumbers) {
@Html.DisplayFor(modelItem => firstname )
@Html.DisplayFor(modelItem => lastname )
@Html.DisplayFor(modelItem => number.Number)
}
}
However when I try to do this inside my datagrid in any shape of form the column remains empty. I was trying simple way to output into the grid approach in the snippet below.
.Columns(col =>
{
// problem is here
col.For(c => c.BillToContact.PhoneNumbers[0].Number).HeaderText("PhoneNumbers1").Width("200px");
col.For(c => c.ID).HeaderText("ID").Width("100px");
col.For(c => c.Name).HeaderText("Name").Width("200px");
col.For(c => c.BillToContact.Name).HeaderText("BillToContactName").Width("200px");
col.For(c => c.BillToContact.Title).HeaderText("Title").Width("200px");
})
Would anyone know how to display the contents of an array were each value is in a separte column which is inside a library which is the datasource for a Infragistics ignite data grid.?
The approach I would take is to add a overlay property to the BillToContact class that returns the appropriate data. This will allow you to handle scenarios where there is nothing in the array or future scenarios where someone wants all of the available phone numbers to be displayed in the column.
Something along the lines of
public string PhoneNumbers1
{
get
{
if ((PhoneNumbers != null) && (PhoneNumbers.Length > 0))
{
return PhoneNumbers[0].Number;
}
else
{
return string.Empty;
}
}
}