Column with template does not use template in EditMode

Hello,

In my grid I only have one template for the column, when row goes to edit mode the only one template is not used :

<SfGrid TValue="CollectiviteTypeOperation" datasource="@typeOperations"
        AllowSorting="true" AllowResizing=true EnableAltRow="true" EnablePersistence="true"
        Width="100%" Height="100%">
    <GridEditSettings AllowEditing="true" Mode="EditMode.Normal" />
    <GridColumns>
        <GridColumn Field="@nameof(CollectiviteTypeOperation.IdTypeOperation)" IsPrimaryKey="true"  Visible="false" />
        <GridColumn Field="@nameof(CollectiviteTypeOperation.Nature)" AllowEditing="false" Width="100px">
            <Template>
                @if (((CollectiviteTypeOperation)context).Nature == "D")
                {
                    <span>Dépenses</span>
                }
                else
                {
                    <span>Recettes </span>
                }
            </Template>
        </GridColumn>
        <GridColumn Field="@nameof(CollectiviteTypeOperation.Libelle)" AllowEditing="false" Width="100%"></GridColumn>
        <GridColumn Field="@nameof(CollectiviteTypeOperation.RevalorisationAutomatique)" Width="105px" TextAlign="@TextAlign.Center" DisplayAsCheckBox="true"></GridColumn>
        <GridColumn Field="@nameof(CollectiviteTypeOperation.PresenceTypeRevalorisation)" Width="150px" TextAlign="@TextAlign.Center" DisplayAsCheckBox="true"></GridColumn>
        <GridColumn Field="@nameof(CollectiviteTypeOperation.PourcentageMaxDepassement)" Width="150px" TextAlign="@TextAlign.Right" EditType="@EditType.NumericEdit"></GridColumn>
        <GridColumn Field="@nameof(CollectiviteTypeOperation.MontantMaxDepassement)" Width="150px" TextAlign="@TextAlign.Right" EditType="@EditType.NumericEdit"></GridColumn>
    </GridColumns>
</SfGrid>

1 Reply 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team July 27, 2020 03:31 PM UTC

Hi Brice, 

Greetings from Syncfusion support. 

We suggest you to use the EditTemplate feature of Grid. With this you can display your custom items during performing editing in Grid. Please refer the below documentation for more details, 

Please use as like the code below, 

 
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="120" AllowEditing="false"> 
    <Template> 
        @if (((Order)context).CustomerID == "D") 
        { 
            <span>Dépenses</span> 
        } 
        else 
        { 
            <span>Recettes </span> 
        } 
    </Template> 
    <EditTemplate> 
        @if (((Order)context).CustomerID == "D") 
        { 
            <span>Dépenses</span> 
        } 
        else 
        { 
            <span>Recettes </span> 
        } 
    </EditTemplate> 
</GridColumn> 


We have also prepared a sample based on your scenario. Please download the sample form the link below, 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Marked as answer
Loader.
Up arrow icon