Skip to content

Commit 0c6ea93

Browse files
committed
fix: cell-editing docs and snippets for Blazor and WC
1 parent 5546d44 commit 0c6ea93

File tree

1 file changed

+15
-32
lines changed

1 file changed

+15
-32
lines changed

doc/en/components/grids/_shared/cell-editing.md

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,14 +1176,12 @@ public webTreeGridCellEdit(args: IgrGridEditEventArgs): void {
11761176
<!-- ComponentEnd: TreeGrid -->
11771177
<!-- end: React -->
11781178
<!-- Blazor -->
1179-
If the value entered in a cell under the **Age** column is below 18 or the value in the **HireDate** column is in the future, the editing will be cancelled and the user will be alerted to the cancellation.
1180-
<!-- end: Blazor -->
1181-
<!-- WebComponents, React -->
1179+
<!-- WebComponents, React, Blazor -->
11821180
<!-- ComponentStart: HierarchicalGrid -->
11831181
If the value entered in a cell under the **Units On Order** column is larger than the available amount (the value under **Units in Stock**), the editing will be cancelled and the user will be alerted to the cancellation.
11841182
<!-- ComponentEnd: HierarchicalGrid -->
11851183
1186-
<!-- end: WebComponents, React -->
1184+
<!-- end: WebComponents, React, Blazor -->
11871185
11881186
<!-- Angular -->
11891187
@@ -1195,45 +1193,30 @@ Here, we are validating two columns. If the user tries to set an invalid value f
11951193
11961194
<!-- ComponentStart: HierarchicalGrid -->
11971195
```typescript
1198-
public webHierarchicalGridCellEdit(event: CustomEvent<IgcGridEditEventArgs>): void {
1199-
const today = new Date();
1200-
const column = event.detail.column;
1201-
if (column.field === 'Debut') {
1202-
if (event.detail.newValue > today.getFullYear()) {
1203-
event.detail.cancel = true;
1204-
alert('The debut date must be in the past!');
1205-
}
1206-
} else if (column.field === 'LaunchDate') {
1207-
if (event.detail.newValue > today) {
1208-
event.detail.cancel = true;
1209-
alert('The launch date must be in the past!');
1196+
public webGridEditingEventsCellEdit(args: CustomEvent<IgcGridEditEventArgs>): void {
1197+
var d = args.detail;
1198+
if (d.column != null && d.column.field == "UnitsOnOrder") {
1199+
if (d.newValue > d.rowData.UnitsInStock) {
1200+
d.cancel = true;
1201+
alert("You cannot order more than the units in stock!")
12101202
}
12111203
}
12121204
}
12131205
```
12141206
12151207
```razor
12161208
// In JavaScript
1217-
igRegisterScript("HandleCellEdit", (ev) => {
1218-
const today = new Date();
1219-
const column = event.detail.column;
1220-
if (column.field === 'Debut') {
1221-
if (event.detail.newValue > today.getFullYear()) {
1222-
event.detail.cancel = true;
1223-
alert('The debut date must be in the past!');
1224-
}
1225-
} else if (column.field === 'LaunchDate') {
1226-
if (event.detail.newValue > today) {
1227-
event.detail.cancel = true;
1228-
alert('The launch date must be in the past!');
1209+
igRegisterScript("WebGridEditingEventsCellEdit", (ev) => {
1210+
var d = ev.detail;
1211+
1212+
if (d.column != null && d.column.field == "UnitsOnOrder") {
1213+
if (d.newValue > d.rowData.UnitsInStock) {
1214+
d.cancel = true;
1215+
alert("You cannot order more than the units in stock!")
12291216
}
12301217
}
12311218
}, false);
12321219
```
1233-
<!-- Blazor -->
1234-
Here, we are validating two columns. If the user tries to change an artist's **Debut** year or an album's **Launch Date**, the grid will not allow any dates that are greater than today.
1235-
<!-- end: Blazor -->
1236-
12371220
12381221
<!-- ComponentEnd: HierarchicalGrid -->
12391222

0 commit comments

Comments
 (0)