Skip to content

Commit 8fcb541

Browse files
AmbrozyCORP\vladimir.bushmanov
andauthored
DataGrid demos - hide context menu in table in dropdown (#28758)
Co-authored-by: CORP\vladimir.bushmanov <vladimir.bushmanov@devexpress.com>
1 parent 8c40326 commit 8fcb541

File tree

6 files changed

+18
-2
lines changed

6 files changed

+18
-2
lines changed

apps/demos/Demos/DataGrid/CustomEditors/Angular/app/app.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
[focusedRowEnabled]="true"
8080
[focusedRowKey]="cellInfo.value"
8181
[hoverStateEnabled]="true"
82+
(onContextMenuPreparing)="$event.items = []"
8283
(onSelectionChanged)="
8384
onSelectionChanged($event.selectedRowKeys, cellInfo, e.component)
8485
"

apps/demos/Demos/DataGrid/CustomEditors/Angular/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class AppComponent {
5858
},
5959
});
6060
}
61-
61+
6262
getSelectedRowKeys<T>(value: T): T[] {
6363
return value !== null && value !== undefined ? [value] : [];
6464
}

apps/demos/Demos/DataGrid/CustomEditors/React/EmployeeDropDownBoxComponent.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const dropDownOptions = { width: 500 };
1212
const ownerLabel = { 'aria-label': 'Owner' };
1313

1414
const EmployeeDropDownBoxComponent = (props) => {
15-
const {data: { value: dataValue }} = props;
15+
const { data: { value: dataValue } } = props;
1616
const initialSelectedRowKeys = dataValue !== null && dataValue !== undefined ? [dataValue] : [];
1717
const [selectedRowKeys, setSelectedRowKeys] = useState(initialSelectedRowKeys);
1818
const [isDropDownOpened, setDropDownOpened] = useState(false);
@@ -24,6 +24,9 @@ const EmployeeDropDownBoxComponent = (props) => {
2424
}, []);
2525

2626
const contentRender = useCallback(() => {
27+
const onContextMenuPreparing = (event: DataGridTypes.ContextMenuPreparingEvent) => {
28+
event.items = [];
29+
};
2730
const onSelectionChanged = (args: DataGridTypes.SelectionChangedEvent) => {
2831
setSelectedRowKeys(args.selectedRowKeys);
2932
setDropDownOpened(false);
@@ -38,6 +41,7 @@ const EmployeeDropDownBoxComponent = (props) => {
3841
height={250}
3942
selectedRowKeys={selectedRowKeys}
4043
hoverStateEnabled={true}
44+
onContextMenuPreparing={onContextMenuPreparing}
4145
onSelectionChanged={onSelectionChanged}
4246
focusedRowEnabled={true}
4347
defaultFocusedRowKey={selectedRowKeys[0]}

apps/demos/Demos/DataGrid/CustomEditors/ReactJs/EmployeeDropDownBoxComponent.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ const EmployeeDropDownBoxComponent = (props) => {
1919
}
2020
}, []);
2121
const contentRender = useCallback(() => {
22+
const onContextMenuPreparing = (event) => {
23+
event.items = [];
24+
};
2225
const onSelectionChanged = (args) => {
2326
setSelectedRowKeys(args.selectedRowKeys);
2427
setDropDownOpened(false);
@@ -31,6 +34,7 @@ const EmployeeDropDownBoxComponent = (props) => {
3134
height={250}
3235
selectedRowKeys={selectedRowKeys}
3336
hoverStateEnabled={true}
37+
onContextMenuPreparing={onContextMenuPreparing}
3438
onSelectionChanged={onSelectionChanged}
3539
focusedRowEnabled={true}
3640
defaultFocusedRowKey={selectedRowKeys[0]}

apps/demos/Demos/DataGrid/CustomEditors/Vue/EmployeeDropDownBoxComponent.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
:height="250"
1717
:selected-row-keys="getSelectedRowKeys(currentValue)"
1818
:hover-state-enabled="true"
19+
:on-context-menu-preparing="onContextMenuPreparing"
1920
:on-selection-changed="onSelectionChanged"
2021
:focused-row-enabled="true"
2122
:focused-row-key="currentValue"
@@ -61,6 +62,9 @@ function getSelectedRowKeys<T>(value: T | null): T[] {
6162
return value !== null && value !== undefined ? [value] : [];
6263
}
6364
65+
const onContextMenuPreparing = (e: DxDataGridTypes.ContextMenuPreparing) => {
66+
e.items = [];
67+
};
6468
const onSelectionChanged = (e: DxDataGridTypes.SelectionChangedEvent) => {
6569
currentValue.value = e.selectedRowKeys[0];
6670

apps/demos/Demos/DataGrid/CustomEditors/jQuery/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ $(() => {
120120
selectedRowKeys: selectedRowKeys,
121121
focusedRowEnabled: true,
122122
focusedRowKey: cellInfo.value,
123+
onContextMenuPreparing: (e) => {
124+
e.items = [];
125+
},
123126
onSelectionChanged(selectionChangedArgs) {
124127
e.component.option('value', selectionChangedArgs.selectedRowKeys[0]);
125128
cellInfo.setValue(selectionChangedArgs.selectedRowKeys[0]);

0 commit comments

Comments
 (0)