-
-
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
[DataGridPro] Update onColumnOrderChange
behaviour to match onRowsOrderChange
#6126
Comments
We do not have demo using it, because it's mostly for internal use. You can use it like other events. Its parameters are simple. you will get the What are you trying to achieve when the drag end occurs? |
Thank you for the link. I think it is a very common setup, in enterprise apps, for state of the grid to be saved in DB. Is it possible to have this even exposed as grid event handler? |
Hi @vbynda-gresham why aren't you using the |
columnHeaderDragEnd
event?
Here is the demo :) I had to use a |
onColumnOrderChange fires event as column dragged over the other column(not dropped yet). If i drag my column over 10 columns, it will fire 10 events. I have not interest in those. I have no interest tying to filter or debounce them. I need to know when the column is dropped, in other words, user finished re-ordering. At this point i can save new column layout. |
@alexfauquette Thank you for the demo https://codesandbox.io/s/eager-shamir-5grln1?file=/demo.tsx. It reproduces exactly what I am talking about. You can see log messages as column being dragged. |
I think then we should change its behavior to match the one for |
columnHeaderDragEnd
event?onColumnOrderChange
behaviour to match onRowsOrderChange
onRowsOrderChange vs. onRowsOrderChanged does it make sense? Do you use a distinction to indicate 'with past tense' that the action is finished vs. in progress. Or maybe add onRowsOrderChangeEnd? |
Yes, multiple |
Pretty much what we are doing. I was hoping to avoid all this craft and use dedicated grid event that shows when column reorder is done. |
What I see in demo there is no event only defaultMuiPrevented info
<DataGridPro
columns={[{ field: "id" }, { field: "username" }, { field: "age" }]}
onColumnOrderChange={(params, event, detials) => {
// THERE IS NO EVENT TYPE "onRowsOrderChangeEnd". HERE event = { defaultMuiPrevented: false }. I AM NOT SURE WHAT IS THE USE OF THAT
console.log({ event });
}}
rows={rows}
/>
https://codesandbox.io/s/blissful-grass-cqolct?file=/demo.tsx:445-471 |
To add to the discussion I find this prop pretty useless unless it emits the current ordering of all of the columns in the grid. I would like to cache and save user preferences as they reorder columns and it is difficult to track that from the params emitted from this event in addition to the issues mentioned above where all that we care about is the final drop position |
Order ID 💳
45466
Duplicates
Latest version
The problem in depth 🔍
Dear Developer,
I can see in your documentation following:
_In addition, column reordering emits the following events that can be imported:
columnHeaderDragStart: emitted when dragging of a header cell starts.
columnHeaderDragEnter: emitted when the cursor enters another header cell while dragging.
columnHeaderDragOver: emitted when dragging a header cell over another header cell.
columnHeaderDragEnd: emitted when dragging of a header cell stops._
I am not quite sure how to do it. Is there an example of it? I would like to use columnHeaderDragEnd event.
onColumnOrderChange is fired multiple times as column dragged through the header. This is not working for me as we are updating API with column order. 'Drag end' would be perfect for us.
Thank you.
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: