Hello,
I am using the MVC wrapper to create the Ignite Grid. I have built ViewModels, since I need to show information from multiple DTOs. So, the DTOs' properties have been flattened in the ViewModel. The definition of the Grid looks like the following:
@(Html.Infragistics().Grid() .ID("FWUserGrid") .PrimaryKey("ID") .Columns(column => { column.For(obj => obj.ID).HeaderText("User ID"); column.For(obj => obj.Name).HeaderText("User Name").Template("${Name}").Key("UserName"); column.For(obj => obj.LoginName).HeaderText("User LoginName"); column.For(obj => obj.Code).HeaderText("User Code"); column.For(obj => obj.CreatedOn).HeaderText("Date Created"); }) .RowActions(actions, "userMasterActionEventHandler") .DataSourceUrl(Url.Action("GetPagedUsers", "User")) .DataBind() .Render())
The above definition throws exception. It works fine If I either remove the Date Created column or set key to "Name".
NOTE: Please note that the Key("UserName") is an extension method which sets the column.key to the the "UserName". The Key extension method looks like this:
public static GridColumnWrapper Key(this GridColumnWrapper gridCol, Expression<Func> propertyExpression) where T: class { var expressionText = ExpressionHelper.GetExpressionText(propertyExpression); gridCol.Column.Key = expressionText; return gridCol; }
It seems worthy to describe the reason for which I have written this extension method: Actually, as I have already described that the ViewModel contains multiple DTOs. So, there is a chance that two DTOs have properties with same name (e.g; Name can appear in more than one DTO). So, when these DTO are flattened in the ViewModel the properties with same name have to be renamed (to avoid duplicate properties). Now, the real cause of doing all this is: I have enabled remote-sorting in the Grid. So, whenever I sort a column, the sort-expression (OrderBy) contains the property name that I gave in the key. And I use this same property name to apply sorting in the my NHibernate query.
Hope this explains the scenario.
Regards,
Arfan Baig
Hi Arfan,
could you post some details about the exception you are getting? Thanks,
Angel