Reputation: 2844
How do I loop through all the columns in MVC Grid? From what I have seems in all the samples it seems that the columns are static. In my case it is dynamic and I want set the property at run time.
Is it possible to set some property say encode for all the columns in a grid?
Upvotes: 1
Views: 1495
Reputation: 2844
Well it was easy once I noted that for loop can be embedded in the columns section
Html.Telerik().Grid(Model.GetDataTable()).Name("MyTestGrid").Pageable().Sortable().Filterable().Groupable().Columns(
columns=>
{
foreach (var column in Model.GetDataTable().Columns)
{
columns.Bound(column.ToString()).Encoded(false);
}
}
).Render();
Upvotes: 1