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
- Create a custom Kendo UI Grid HtmlHelper.
-
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"); } } }
-
Use
Html.MyGrid
instead ofHtml.Grid
.@(Html.MyGrid<Model>() .Name("grid") .Columns(columns => { ... }) .DataSource(dataSource => dataSource ... ) )