Skip to content

Commit

Permalink
Add description to how-to
Browse files Browse the repository at this point in the history
  • Loading branch information
tsvetomir committed Jan 20, 2016
1 parent e023618 commit 5e1db42
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/aspnet-mvc/helpers/grid/how-to/grid-bind-to-datatable.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,28 @@ description: Bind the Kendo UI MVC Grid to a DataTable

This project demonstrates how to bind the UI for ASP.NET MVC Grid to a DataTable.

> The same approach is applicable when binding to any `dynamic` model.
## Sample project

The full source code of the sample project is available on GitHub:
[Bind the Kendo UI MVC Grid to a DataTable](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/binding-to-datatable)

## Problems
There are two main problems that this sample solves.

### Editing

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

The DataTable metadata contains this information.
We can pull it into the model definition as illustrated in
[Index.cshtml:29](https://github.com/telerik/ui-for-aspnet-mvc-examples/blob/master/grid/binding-to-datatable/KendoUIMVC5/Views/Home/Index.cshtml#L29)

### Aggregates

The aggregates suffer from 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.

The solution is to provide type information for the requested aggregates in the DataSourceRequest object. See [HomeController.cs:33](https://github.com/telerik/ui-for-aspnet-mvc-examples/blob/master/grid/binding-to-datatable/KendoUIMVC5/Controllers/HomeController.cs#L33)

0 comments on commit 5e1db42

Please sign in to comment.