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.
Perfect, thank you!
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.
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