views:

87

answers:

1

hi,

I have an asp.net MVC application where I am using telerik grid to show the data/records.I am using the Entity Model.

My requirement is that sometime I want to show only some of the columns specified at the runtime/may the user select. How do I bind View with only those columns as selected by the user . Initially view is binded with Model class with all columns .

Is there any other way other than telerik to show the customized columns as selected by the user then it will be also OK .

Thanks In Advance DNM

+1  A: 

You could customize the columns that are shown using the Columns method. You need to have the information about which columns need to be shown in the view model so that you can at runtime select the columns to show:

<%= Html.Telerik()
        .Grid(Model.Customers)
        .Name("Grid")
        .Columns(columns =>
        {
            if (Model.IsShowFirstName)
            {
                columns.Bound(customer => customer.FirstName);
            }
            if (Model.IsShowLastName)
            {
                columns.Bound(customer => customer.LastName);
            }
        })
%>
Darin Dimitrov
Is the IsShowFirstName is the property of the Model class
Dharam Narayan
Yes, it is a property of the view model to which the view is strongly typed.
Darin Dimitrov