I'm trying to display 4 view model properties as columns in an igGrid control. I'm creating the grid in a Razor view using the chaining method. The grid columns are set up as follows:
@(Html.Infragistics().Grid<MediaViewModel>() .ID("grid").AutoGenerateColumns(false) .Columns(c => { c.For(media => media.Media.ID).DataType("number").HeaderText("ID"); c.For(media => media.Media.Description).DataType("string").HeaderText("Description"); c.For(media => media.Option1).DataType("string").HeaderText("Option 1"); c.For(media => media.Option2).DataType("string").HeaderText("Option 2"); }).ClientDataSourceType(ClientDataSourceType.JSON).DataSourceUrl(Url.Action("GetGridData")).DataBind().Render())
And the view model looks like this:
public class MediaViewModel {public EntityLayer.EntityObjects.Media Media { get; set; }
public string Option1 { get; set; }
public string Option2 { get; set; }
}
Note that the Media class referred to as a property in the MediaViewModel class, contains several public properties, two of which are ID (int) and Description (string).
So, the issue is that the ID and the Description cells in the grid are empty, but the Option1 and Option2 text is displayed fine. I realise I could get it working if I flattened the MediaViewModel class so that the ID and Description properties belong immediately to the MediaViewModel class, but I'd like to keep the current structure.
Please help me with this as I can't find this issue listed anywhere. The lambda expressions for the columns ID and Description refer to the properties I want to display, so I'm not sure what's going on.
Kind regards,
Stephen
2 suggestions
Hope this helps,
Regrads
Thanks for your reply, but the Media object is definitely initialised. I've checked in the VS debugger and I have verify that the Media object for all items in the collection of MediaViewModel has been populated. I have also verified using the Chrome browser developer tools that the data source is populated correctly for the Infragistics igGrid. The problem appears to be with displaying the Media values, not due to the population.
Cheers,