This is a ModelBinder designed to consume a http request and dynamically build a json serializable object for the Kendo UI Grid datasource. AutoMapper is used to support mapping from ViewModel <> Entity.


Keywords
Grid, Dynamic, Kendo, AutoMapper, Model, MVC, ModelBinder, Binder, kendo-ui
License
GPL-3.0
Install
Install-Package KendoGridBinder -Version 3.2.0

Documentation

KendoGridBinder

Build status

Versions

NuGet Frameworks NuGet
KendoGridBinder .NET 4.5 NuGet Badge
KendoGridBinder.AspNetCore .NET 4.6.1
NETStandard 1.6
NETStandard 2.0
NuGet Badge

Demo

A live demo can be found here.

Action Method

[HttpPost]
public JsonResult Grid(KendoGridMvcRequest request)
{
    var employees = new List<Employee>
    {
        new Employee { EmployeeId = 1, FirstName = "Bill", LastName = "Jones", Email = "bill@email.com" },
        new Employee { EmployeeId = 2, FirstName = "Rob", LastName = "Johnson", Email = "rob@email.com" },
        new Employee { EmployeeId = 3, FirstName = "Jane", LastName = "Smith", Email = "jane@email.com" }
    };

    var grid = new KendoGridEx<Employee, EmployeeVM>(request, employees.AsQueryable());
    return Json(grid);
}

HTML

<div id="grid"></div>

Script

<script>
    var url = '@Url.Action("Grid")';

    var dataSource = {
        serverPaging: true,
        serverSorting: true,
        serverFiltering: true,
        pageSize: 20,
        transport: {
            read: {
                type: 'post',
                dataType: 'json',
                url: url
            }
        },
        schema: {
            data: 'Data',
            total: 'Total',
            model: {
                id: 'Id',
                fields: {
                    FirstName: { type: 'string' },
                    LastName: { type: 'string' },
                    Email: { type: 'string' }
                }
            }
        }
    };

    $('#grid').kendoGrid({
        dataSource: dataSource,
        height: 400,
        columns: [
            { field: 'FirstName', title: 'First Name' },
            { field: 'LastName', title: 'Last Name' },
            { field: 'Email' }
        ],        
        filterable: true,
        sortable: true,
        pageable: true
    });
</script>