I believe ValueAccessor would work but could not find a Blazor example

            <EjsGrid @ref="PilotGrid" ID="PilotGrid" DataSource="@Program.pilots" AllowSelection="true" AllowSorting="true" AllowMultiSorting="true" AllowPdfExport="true">
                <GridEvents RowSelected="GetSelected" TValue="Pilot"></GridEvents>
                <GridSelectionSettings CellSelectionMode="CellSelectionMode.Box" Type="SelectionType.Single"></GridSelectionSettings>
                <GridColumns>
                    <GridColumn Field=@nameof(Pilot.ID) HeaderText="CAP ID" TextAlign="TextAlign.Center" Width="60"></GridColumn>
                    <GridColumn Field=@nameof(Pilot.Name) HeaderText="Name" TextAlign="TextAlign.Center" Width="120"></GridColumn>
                    <GridColumn Field=@nameof(Pilot.Unit) HeaderText="Unit" TextAlign="TextAlign.Center" Width="60"></GridColumn>
                    <GridColumn Field=@nameof(Pilot.QualifiedFor172) HeaderText="172" TextAlign="TextAlign.Center" Width="40"></GridColumn>
                    <GridColumn Field=@nameof(Pilot.QualifiedFor182) HeaderText="182" TextAlign="TextAlign.Center" Width="40"></GridColumn>
                    <GridColumn Field=@nameof(Pilot.Mobile_Number) HeaderText="Mobile Number" TextAlign="TextAlign.Center" Width="100"></GridColumn>
                    <GridColumn Field=@nameof(Pilot.Availability) HeaderText="Availability" TextAlign="TextAlign.Center" Width="200"></GridColumn>
                </GridColumns>
            </EjsGrid>

Pilot.QualifiedFor172 and Pilot.QualifiedFor182 are type bool so they show as True or False which is fine for me but for average user not so much. I want to do something like show X for True and nothing for False. I have some ways to accomplish but I wondered if utilizing ValueAccessor would be the most optimal.

Attachment: screen_shot_25f84cd2.zip

3 Replies

RS Renjith Singh Rajendran Syncfusion Team February 19, 2020 10:10 AM UTC

Hi Gary, 

Thanks for contacting Syncfusion support. 

We suggest you to use the “Column Template feature of Grid”, instead of ValueAccessor, with this support you can define the Boolean valued columns as template columns. Now you can define the column template by checking for the value in Boolean columns and it displays the values accordingly(as X for true and “” for false). Please use the code below, 

 
        <GridColumn Field=@nameof(EmployeeData.QualifiedFor172) HeaderText="QualifiedFor172" Width="100"> 
            <Template> 
                @{ 
                    var a = context as EmployeeData; 
                    if (a.QualifiedFor172 == true) 
                    { 
                        <span>X</span> 
                    } 
                    else 
                    { 
                        <span></span> 
                    } 
                } 
            </Template> 
        </GridColumn> 
        <GridColumn Field=@nameof(EmployeeData.QualifiedFor182) HeaderText="QualifiedFor182" Width="100"> 
            <Template> 
                @{ 
                    var a = context as EmployeeData; 
                    if (a.QualifiedFor182 == true) 
                    { 
                        <span>X</span> 
                    } 
                    else 
                    { 
                        <span></span> 
                    } 
                } 
            </Template> 
        </GridColumn> 


 
Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 



GA Gary February 19, 2020 01:26 PM UTC

Thanks I would never haved guessed that... You should add to the online docs


RS Renjith Singh Rajendran Syncfusion Team February 20, 2020 04:51 AM UTC

Hi Gary, 

We are glad to hear that our suggestion helped you in achieving your requirement.  

And thanks for your suggestion. We have already added this topic “Using conditions inside template” in our online documentations. Please refer the below link for more details, 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 


Loader.
Up arrow icon