More in this section
Blogs RSS feed

Building Sitefinity MVC Widgets with KendoUI Grid

by Stanislav Velikov
Building Sitefinity MVC widgets with KendoUI controls has some specifics that I will outline in this blog post.

By default the Kendo Grid can be directly bound to the MVC Action that will return the json for populating the databound control. In Sitefinity CMS, however, it is necessary to bind the Kendo Grid to an artificial URL that returns the json result to populate the Kendo Grid.

Here is how this is done:

1. In the MVC View use Kendo Grid bound to a relative to the current application URL which doesn`t represent any page, but its artificial one that will only be used to bind the Grid.

    columns =>
        columns.Bound(e => e.Name);
        columns.Bound(e => e.Age);
    .DataSource(ds => ds.Ajax()
        .Read(a => a.Url("/json/employees/listemployees"))
        .Model(m => {
            m.Id(p => p.Name);
            m.Field(p => p.Age);

2. The ActionResult that populates the Grid with data is:

        public ActionResult ListEmployees(DataSourceRequest request)
            var pagingParam = int.Parse(HttpContext.Request.Form["page"]);
            var pageSizeParam = int.Parse(HttpContext.Request.Form["pageSize"]);
            var employees = new List<EmployeesModel>()
                new EmployeesModel() { Name = "Jane Doe", Age = 23, BirthDate = DateTime.Now, SocialSecurityNumber = "015-23-2356" },
                new EmployeesModel() { Name = "John Smith", Age = 32, BirthDate = DateTime.Now, SocialSecurityNumber = "015-23-2356" },
            var result = employees.ToDataSourceResult(request);
            return Json(result, JsonRequestBehavior.AllowGet);

3. The artificial route to which the Grid is bound is registered in Global.asax as shown below.

protected void Application_Start(object sender, EventArgs e)
           Bootstrapper.MVC.MapRoute("json", "json/{controller}/{action}/{id}", new { controller = "Employees", action = "ListEmployees", id = (string)null });

The sample source code can be downloaded here. KendoUI for MVC has to also be installed for the site to use the Kendo controls, here is the documentation for this.


Leave a comment
  1. Stuart Oct 29, 2013
    Does this work in Hybrid mode?
  2. Dustin Jul 08, 2014
    @Stuart - yes...I'm currently using this approach on SiteFinity 6.2 in hybrid mode.
  3. Bishoy hanna Jul 16, 2014
    It worked with me perfectly
  4. Daniel Plomp Mar 25, 2015
    Just curious if this is still the case when using Pure MVC mode inside a Sitefinity 8.0 application?
  5. Rajeev May 14, 2015
    Do u have an example how to show any custom module of sitefinity results on the kendo grid.

    Leave a comment