-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[data grid] Column reorder does not work on tablet/mobile #14362
Comments
Hi @lucal-mms, I'm here to help you with any bugs, questions, or contributions you have. Let's work together to solve this issue! I found some similar issues and discussions related to column reordering on mobile/tablet devices:
For handling touch events in the Data Grid component, the Here is a relevant code snippet showing the integration: useGridApiEventHandler(apiRef, 'columnHeaderDragStart', handleDragStart);
useGridApiEventHandler(apiRef, 'columnHeaderDragEnter', handleDragEnter);
useGridApiEventHandler(apiRef, 'columnHeaderDragOver', handleDragOver);
useGridApiEventHandler(apiRef, 'columnHeaderDragEnd', handleDragEnd);
useGridApiEventHandler(apiRef, 'cellDragEnter', handleDragEnter);
useGridApiEventHandler(apiRef, 'cellDragOver', handleDragOver);
useGridApiOptionHandler(apiRef, 'columnOrderChange', props.onColumnOrderChange); For touch events related to resizing, the const handleTouchStart = useEventCallback((event: any) => {
const cellSeparator = findParentElementFromClassName(
event.target,
gridClasses['columnSeparator--resizable'],
) as HTMLElement | null;
if (!cellSeparator) {
return;
}
const touch = event.changedTouches[0];
if (touch != null) {
touchId.current = touch.identifier;
}
const columnHeaderElement = findParentElementFromClassName(
event.target,
gridClasses.columnHeader,
) as HTMLDivElement;
const field = getFieldFromHeaderElem(columnHeaderElement);
const colDef = apiRef.current.getColumn(field);
storeReferences(colDef, cellSeparator, touch.clientX);
const doc = ownerDocument(event.currentTarget as HTMLElement);
doc.addEventListener('touchmove', handleTouchMove);
doc.addEventListener('touchend', handleTouchEnd);
});
const handleTouchMove = useEventCallback((nativeEvent: any) => {
const finger = trackFinger(nativeEvent, touchId.current);
if (!finger) {
return;
}
let newWidth = computeNewWidth(
initialOffsetToSeparator.current!,
(finger as CursorCoordinates).x,
refs.columnHeaderElement!.getBoundingClientRect(),
resizeDirection.current!,
);
newWidth = clamp(newWidth, refs.colDef!.minWidth!, refs.colDef!.maxWidth!);
updateWidth(newWidth);
const params: GridColumnResizeParams = {
element: refs.columnHeaderElement,
colDef: refs.colDef!,
width: newWidth,
};
apiRef.current.publishEvent('columnResize', params, nativeEvent);
});
const handleTouchEnd = useEventCallback((nativeEvent: any) => {
const finger = trackFinger(nativeEvent, touchId.current);
if (!finger) {
return;
}
finishResize(nativeEvent);
}); These handlers ensure that touch events are properly managed to support both column reordering and resizing features in the Data Grid component [5][6]. |
There should be an out-of-the-box solution for this! |
This feature is currently not implemented. |
Yes, this feature should be added to drag columns on touch screen such as tablets. I temporarily used Ag-Grid because it supported drag-and-drop column on touch screen. The downside is Ag-Grid package is quite heavy. I will switch back to MUI when this feature is implemented for touch screen. |
Since this touches the same problem as #9330 I will close this as a duplicate. |
@lucal-mms: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
Steps to reproduce
Link to live example: https://codesandbox.io/p/sandbox/affectionate-star-kfd8qj
(Example from official docs: https://mui.com/x/react-data-grid/column-ordering/)
Steps:
Current behavior
When trying to drag-and-drop columns on mobile/tablet to reorder them, nothing happens.
There is no icon present to reorder by dragging that icon either.
I even went as far as to clone the source code to try and see and there's an icon for column reorder that's not used:
Found in filegridIconSlotsComponent.ts .
Expected behavior
Column reorder should work on tablet/mobile too.
Either add an icon which can be dragged/dropped by the user via tap hold, or add the possibility to drag-and-drop column headers like on bigger devices (laptop/desktop).
Context
One of the reasons we chose and paid forMUI PRO was because of this feature.
We have several users that use the app on tablet/mobile in landscape mode for quick access of data on the go (in meetings for example, when you don't have your laptop on hand).
Your environment
No response
Search keywords: column reorder tablet mobile
Order ID: 89922
Search keywords:
The text was updated successfully, but these errors were encountered: