New to Telerik UI for ASP.NET MVC? Download free 30-day trial

Bind the Grid to DataTable

The following sample project demonstrates how to bind the Kendo UI Grid to a DataTable in ASP.NET MVC applications.

This approach is applicable when binding to any dynamic model.

Sample Project

The sample project example resolves two main issues, which are related to:

To see the complete project, refer to this repository on GitHub.

Editing

The Grid does not have an instance to a model object and cannot infer field types. You need to provide the model field definitions yourself.

Solution

The metadata of the DataTable contains this information. Pull it into the model definition as illustrated in Index.cshtml:29.

Aggregates

The aggregates suffer from a lack of type-information as well. The ToDataSourceResult helper does not have information about the field types and fails to compute the aggregates on its own.

Solution

Provide type-information for the requested aggregates in the DataSourceRequest object. For more information on this issue, refer to HomeController.cs:33.

See Also

In this article