This example shows how Telerik Grid for ASP.NET MVC can infer its columns based on the properties of the data item it is bound to. A columns is created for every public property of simple type (integer, string, date, enum and boolean).
Column titles are inferred from the property name using pascal-case splitting - for example if the property name is CustomerID the inferred column title will be "Customer ID".
The following is an example of simple definition of the Grid:
<%= Html.Telerik().Grid(Model)
.Name("Grid")
.Sortable()
.Scrollable()
.Pageable()
%>
The AutoGenerate method can be used to further customize the generated columns' settings:
<%= Html.Telerik().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.AutoGenerate(column =>
{
column.Width = "150px";
if (column.Member == "CustomerID")
column.Visible = false;
});
})
%>