Display Yes - No instead of True - False

Screenshot (357).png

I have a field name Posted. I was able to display Yes -No instead of True- False. I was wondering if how can I display it on filter and selections.


3 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team November 18, 2021 05:04 AM UTC

Hi Belle,  
 
Thanks for contacting Syncfusion support.  
 
Query: “I have a field name Posted. I was able to display Yes -No instead of True- False. I was wondering if how can I display it on filter and selections. 
 
We have analyzed your query and we suggest you to achieve your requirement using ColumnTemplate and FilterItemTemplate feature of Grid. refer the below code example for your reference 
 
<SfGrid DataSource="@Orders" AllowPaging="true" AllowFiltering="true"> 
    <GridFilterSettings Type="FilterType.Excel"></GridFilterSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn> 
        <GridColumn Field=@nameof(Order.Notification) HeaderText="Notify" Width="150"> 
            <FilterItemTemplate> 
                @{ 
                    var cont = context as FilterItemTemplateContext; 
                    if (cont.Value.ToString().ToLower() == "true") 
                    { 
                        <div>Yes</div> 
                    } 
                    else if (cont.Value.ToString().ToLower() == "false") 
                    { 
                        <div>No</div> 
                    } 
                } 
            </FilterItemTemplate> 
            <Template> 
                @{  
                    var ord = context as Order; 
                        if (ord.Notification) 
                        { 
                            <div>Yes</div> 
                        } 
                        else 
                        { 
                            <div>No</div> 
                        } 
                } 
            </Template> 
        </GridColumn> 
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn> 
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
    </GridColumns> 
</SfGrid> 
 
 
Refer the below screenshot for your reference 
 
 
 
Refer our UG documentation for your reference 
 
 
Regards, 
Vignesh Natarajan 



BC Belle Cruz replied to Vignesh Natarajan November 18, 2021 05:48 AM UTC

Thank you for the fast reply. But I want to display the Yes first.



VN Vignesh Natarajan Syncfusion Team November 19, 2021 03:21 AM UTC

Hi Belle,  

Thanks for the update.  

Query: “But I want to display the Yes first. 

We would like to inform that by default list inside the Excel / Checkbox filter dialog will be sorted in alphabetical order. So actual values for Boolean column will be True and False. While arranging these value in alphabetical order, false value will come first. Hence in filter dialog also No is displayed first.  

This is default behavior of excel dialog and values order cannot be modified. Please get back to us if you have further queries. 

Regards, 
Vignesh Natarajan

Marked as answer
Loader.
Up arrow icon