This is a migrated thread and some comments may be shown as answers.

Boolean Columns

3 Answers 1548 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 04 Oct 2019, 12:23 PM

Is it possible to show something else than "True/False" for a Boolean Column? 

 

CheckBox, PNG of a checkmark, a light, etc...

3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 04 Oct 2019, 12:25 PM

Hello Michael,

I am pasting here my response from your private ticket on the subject:

You can do this by using templates - the <Template> for read mode, and the <EditorTemplate> for edit mode in case you want to alter the default checkbox. Here's more information about them: https://docs.telerik.com/blazor-ui/components/grid/templates.

 

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor
0
Greg
Top achievements
Rank 1
answered on 08 Feb 2021, 04:26 AM
Please post a specific example of how to do this here.
0
Eric R | Senior Technical Support Engineer
Telerik team
answered on 08 Feb 2021, 03:51 PM

Hi Greg,

We like to make all demos included with the UI framework available publicly. In this case, the UI for Blazor demos are available at Blazor Components Demos and Examples - Telerik UI for Blazor and the Grid Template demo is available at Blazor DataGrid Demos - Templates | Telerik UI for Blazor. For specific example, see the following code and output section. 

Simple Boolean Template

In the following sample, if the IsActive property is true it will display Is Active and if it is false it will display Not Active.

Page Markup and Code

@page "/"
@using GridTemplateBooleanColumn.Data
@inject ProductService ProductService

<h1>Grid Template Column</h1>

<TelerikGrid Data="Products">
    <GridColumns>
        <GridColumn Field="@nameof(Product.ID)" Title="@nameof(Product.ID)" Editable="false"></GridColumn>
        <GridColumn Field="@nameof(Product.Name)" Title="@nameof(Product.Name)"></GridColumn>
        <GridColumn Field="@nameof(Product.IsActive)" Title="@nameof(Product.IsActive)">
            <Template>
                @{
                    Product product = context as Product;
                    if (product.IsActive)
                    {
                        <span>Is Active</span>
                    }
                    else
                    {
                        <span>Not Active</span>
                    }
                }
            </Template>
        </GridColumn>
    </GridColumns>
</TelerikGrid>

<br />


@code {
    IEnumerable<Product> Products;

    protected override void OnInitialized()
    {
        Products = ProductService.GetProducts();
    }
}

The Output

Wrapping Up

I hope the public demos and the previous example illustrates the possibilities with changing the output value of a Boolean Column with Templates.

If it doesn't, I encourage opening a Support Ticket through your Telerik Account. This will give us the opportunity to address more specific questions.

Please let me know if you need any additional information. Thank you for using the UI for Blazor Forums.

Regards,


Eric R | Senior Technical Support Engineer
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Michael
Top achievements
Rank 2
Answers by
Marin Bratanov
Telerik team
Greg
Top achievements
Rank 1
Eric R | Senior Technical Support Engineer
Telerik team
Share this question
or