|
<div>Disable editing for all the columns </div>
<SfGrid ID="Grid1" DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" Height="315">
<GridEditSettings AllowAdding="true" AllowEditing="false" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings>
<GridColumns>
. . .
</GridColumns>
</SfGrid>
. . .
@code{
. . .
} |
|
<div>Disable editing for particular columns </div>
<SfGrid ID="Grid2" DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" Height="315">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings> - //here we have enabled adding, editing , deleting operations for all columns
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" ValidationRules="@(new { required=true})" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" AllowEditing="false" ValidationRules="@(new { required=true})" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" AllowEditing="false" EditType="EditType.DatePickerEdit" Format="d" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"></GridColumn>
. . .
</GridColumns>
</SfGrid>
@code{
. . .
} |
|
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })" Height="315">
<GridEditSettings AllowAdding="true" AllowEditing="false" AllowDeleting="true" Mode="EditMode.Batch"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" ValidationRules="@(new ValidationRules { Required = true })" Type="ColumnType.Number" Width="120"></GridColumn>
. . .
</GridColumns>
</SfGrid> |
|
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })" Height="315">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" ValidationRules="@(new ValidationRules { Required = true })" Type="ColumnType.Number" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" AllowEditing="false" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" EditType="EditType.DatePickerEdit" Format="d" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"></GridColumn>
. . .
</GridColumns>
</SfGrid> |
|
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })" Height="315">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" ValidationRules="@(new ValidationRules { Required = true })" Type="ColumnType.Number" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" AllowAdding="false" Width="120"></GridColumn>
. . .
</GridColumns>
</SfGrid>
|
I'm having the same issue. I have the code shown below. I have set allowEditing="false" and allowAdding="true" on two columns. But when I click on the add button, I'm not able to provide data for these two columns and I need to. See image below. Thanks
|
App.component.ts
cellEdit(args) { if (
args.type === 'edit' &&
(args.columnName === 'CustomerID' || args.columnName === 'OrderDate')
) {
args.cancel = true;
}
} |
|
App.component.html
<div class="control-section">
<div class="col-lg-9">
<ejs-grid #grid id='Normalgrid' (cellEdit)="cellEdit($event)" [dataSource]='data' allowPaging='true'
[pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='140' textAlign='Right' isPrimaryKey='true'
[validationRules]='orderidrules'></e-column>
<e-column field='CustomerID' headerText='Customer ID' width='140' [validationRules]='customeridrules'>
</e-column>
<e-column field='Freight' headerText='Freight' width='140' format='C2' textAlign='Right'
editType='numericedit' [validationRules]='freightrules'></e-column>
<e-column field='OrderDate' headerText='Order Date' width='120' editType='datetimepickeredit'
[format]='formatoptions' textAlign='Right'></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width='150' editType='dropdownedit'
[edit]='editparams'></e-column>
</e-columns>
</ejs-grid>
</div> |