New to Kendo UI for jQuery? Download free 30-day trial

Set Configuration Property Globally on the Server for Multiple Grids

Environment

Product Progress® Telerik® UI Grid for ASP.NET MVC
Product Version 2018.2.620

Description

How can I add No Data Found as a global template for all Grid in my application and show it when no records are available?

Solution

  1. Create a custom Kendo UI Grid HtmlHelper.
  2. In the custom HtmlHelper, set the NoRecords property.

    The following example demonstrates how to create a custom MyGrid HtmlHelper.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using Kendo.Mvc.UI;
    
    namespace MyNamespace
    {
        public static class MyHtmlHelperExtensions
        {
            public static Kendo.Mvc.UI.Fluent.GridBuilder<T> MyGrid<T>(this HtmlHelper helper, string name)
                where T : class
            {
                return helper.Kendo().Grid<T>()
                .NoRecords("No data found");
            }
        }
    }
    
  3. Use Html.MyGrid instead of Html.Grid.

    @(Html.MyGrid<Model>()
      .Name("grid")
      .Columns(columns =>
      {
       ...
      })
      .DataSource(dataSource => dataSource
       ...   
      )
    )
    
In this article