AllowEditing="false" on GridColumn ignored

Hello,

i have an SfGrid directly bound to an IEnumerable (a list) of data.

I have one column (GuestId) which should allow the user to chose a guest (from a dropdownlist) but ONLY on INSERT, it should not allow the user to alter this field when UPDATING the row.

I thought that all i had to do was to add AllowEditing="false" AllowAdding="true" to my GridColumn, but it seems that  AllowEditing="false" is simply ignored. Please note that this GridColumn uses an EditTemplate to display a dropdownlist.

What am i doing wrong?

Here is a part of the SfGrid razor code for your reference:

<SfGrid ID="EbikeResGrid" @ref="ebikeResGrid" DataSource="@ebikeRes" AllowPaging="true" AllowFiltering="true" AllowSorting="true" AllowSelection="true" Toolbar="@(new List<ItemModel>() { new ItemModel { Id="btnAddEbikeRes", Text="Add", PrefixIcon="e-add" } })">
                                <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" ShowDeleteConfirmDialog="true" AllowEditOnDblClick="false"></GridEditSettings>
                                <GridEvents OnActionBegin="ActionBeginHandler" OnActionComplete="ActionCompleteHandler" OnToolbarClick="OnToolbarClick" TValue="EbikeResModelDto"></GridEvents>
                                <GridColumns>
                                    <GridColumn Field="EbikeResId" IsPrimaryKey="true" Visible="false"></GridColumn>
                                    <GridColumn Field="GuestId" HeaderText="Guest" TextAlign="TextAlign.Left" AllowEditing="false" AllowAdding="true" ValidationRules="@(new ValidationRules { Required = true })">
                                        <FilterTemplate></FilterTemplate>
                                        <Template>
                                            <PrintGuestFullName GuestId="(context as EbikeResModelDto).GuestId" />
                                        </Template>
                                        <EditTemplate>
                                            <SfDropDownList TItem="GuestModelDto" TValue="int" DataSource="@guests" @bind-Value="@((context as EbikeResModelDto).GuestId)">
                                                <DropDownListFieldSettings Text="GuestFullName" Value="GuestId"></DropDownListFieldSettings>
                                            </SfDropDownList>
                                        </EditTemplate>
                                    </GridColumn>
                                    <GridColumn Field="EbikeResStartDate" HeaderText="Start Date" EditType="EditType.DatePickerEdit" Format="d" DefaultValue="@DateTime.Today" Type="ColumnType.Date" TextAlign="TextAlign.Center"></GridColumn>


Thank you.


5 Replies

JP Jeevakanth Palaniappan Syncfusion Team November 17, 2021 06:52 AM UTC

Hi Luca, 

Greetings from Syncfusion support. 

We have validated your query and we would like to inform you that AllowEditing property in GridColumn will be applied only if you didn’t use EditTemplate in that column. If you are using EditTemplate then the component in the editform will be rendered based on the properties you have set in the corresponding component(Dropdown) rendered in the EditTemplate. So to enable/disable the dropdown component, you have to use the Enabled property of SfDropDownList. 

Please refer the below documentation to set Enabled property. In this we have set Enabled property for NumericTextBox as an example. 

API reference for Enabled property in Dropdown 

Please get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 



LT Luca T November 17, 2021 08:15 AM UTC

Perfect, thank you!



JP Jeevakanth Palaniappan Syncfusion Team November 18, 2021 04:11 AM UTC

  
Hi Luca, 

You are most welcome. Please get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 



SH s h September 11, 2024 05:45 AM UTC

Hello

I have set AllowEditing="false" on a GridColumn, but the column becomes editable when adding a new record. I would like to ensure that the column is always non-editable, even during the "Add" operation. Could you please advise if there is a way to achieve this?

Alternatively, I would be open to hiding the column only in the dialog during the "Add" operation. Any guidance or suggestions would be greatly appreciated.

Thank you very much for your assistance.



NP Naveen Palanivel Syncfusion Team September 13, 2024 12:18 AM UTC

Hi s h,

To achieve non-editability during the add operation, you can either set the AllowAdding property to false or set the IsIdentity property to true. When you set the IsIdentity property to true, that column becomes read-only during both editing and adding operations.


Regards,
Naveen


Loader.
Up arrow icon