New to Telerik UI for ASP.NET Core? Download free 30-day trial

Rendering Icons for Boolean Columns in the Grid


Product Telerik UI for ASP.NET Core Grid
Progress Telerik UI for ASP.NET Core version Created with the 2023.1.117 version


How can I render icons for a Boolean column in the Telerik UI for ASP.NET Core Grid?


To achieve the desired scenario:

  1. Specify a column template for the Boolean column by using the ClientTemplate() configuration method and provide a function handler.
  2. Within the handler, replace the default true and false values by using the conventional Kendo UI Web Font Icons.
        .Columns(columns => {
            columns.Bound(p => p.ProductName);
            columns.Bound(p => p.UnitPrice).Width(140);
            columns.Bound(p => p.UnitsInStock).Width(140);
            columns.Bound(p => p.Discontinued).ClientTemplate("#=discTemplate(data)#").Width(100); // Use the template syntax to invoke the function whilst passing the data object of the current model.
            columns.Command(command => command.Destroy()).Width(150);
        .ToolBar(toolbar => {
        .Editable(editable => editable.Mode(GridEditMode.InCell))
        .DataSource(dataSource => dataSource
            .Model(model => model.Id(p => p.ProductID))
            .Create("Editing_Create", "Grid")
            .Read("Editing_Read", "Grid")
            .Update("Editing_Update", "Grid")
            .Destroy("Editing_Destroy", "Grid")
    <script type="text/javascript">
       function discTemplate(data) { // Render an icon based on a ternary operator evaluation.
             return data.Discontinued ? "<span class='k-icon k-i-check'></span>" : "<span class='k-icon k-i-x'></span>"

For the complete implementation of the suggested approach, refer to the Telerik REPL example on rendering icons for a Boolean column in the Grid.

See Also

In this article