Adding column at run time based on condition

Aug 21, 2013 at 5:53 PM
How can we add column at run time based on if condition.If condition is true,Column 'll be added.Otherwise It should be hidden.
Coordinator
Aug 22, 2013 at 10:16 AM
Hi, you can check condition in the Columns method:
@Html.Grid(Model.Grid).Columns(columns=>{
        if (Model.ShowNumberColumn)
        {
            columns.Add(o => o.Number)
                    .Titled("Number");
        }
...
})
Aug 27, 2013 at 10:55 AM
if (HttpContext.Current.Session["role"].ToString() == "Auditor")
{
    columns.Add(o=>o.CurrentStatus)
            .Titled("Status")
            .SetWidth(150);
}
i did the same but error comes.

Cannot convert lambda expression to type 'GridMvc.Columns.IGridColumn<Audit_Management.Models.ProjectLeadIssue>' because it is not a delegate type at
o=>o.CurrentStatus
Coordinator
Aug 27, 2013 at 2:29 PM
I repeate your code and don't have any problems. Can you show all your grid layout/