You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Those methods attached to apiRef are actually event handlers and should not be on apiRef.
ApiRef goal is to allow users to manipulate the grid. startResizeOnMouseDown, onColItemDragStart, onColHeaderDragOver... are not meaningful.
Something like options.onColumnResize or options.onColumnReordered are more appropriate.
To get the effect required by those methods, we can just publish the event from the component and subscribe to the event in the hook to handle it.
We can also provide a setColumnWidth method on the api that would allow to only update the col width, using the state, and firing onColumnResize once done.
Similarly we can provide a setColumnIndexmethod on the api that would allow to update the col position, using the state, and firing onColumnReorder event once done.
I agree. There was a similar request for having an onColumnReordered on the grid itself.
oliviertassinari
changed the title
Refactor/Remove ColumnReorderApi and ColumnResizeApi
[DataGrid] Refactor/Remove ColumnReorderApi and ColumnResizeApi
Mar 13, 2021
Summary 💡
Those methods attached to apiRef are actually event handlers and should not be on apiRef.
ApiRef goal is to allow users to manipulate the grid.
startResizeOnMouseDown
,onColItemDragStart
,onColHeaderDragOver
... are not meaningful.Something like
options.onColumnResize
oroptions.onColumnReordered
are more appropriate.To get the effect required by those methods, we can just publish the event from the component and subscribe to the event in the hook to handle it.
We can also provide a
setColumnWidth
method on the api that would allow to only update the col width, using the state, and firing onColumnResize once done.Similarly we can provide a
setColumnIndex
method on the api that would allow to update the col position, using the state, and firing onColumnReorder event once done.related to #1167
The text was updated successfully, but these errors were encountered: