.NET MAUI TreeDataGrid Columns Reordering
The .NET MAUI TreeDataGrid exposes a reordering feature allowing the user to drag and drop columns and change their order.
The following properties control the reordering feature:
-
CanUserReorderColumns
(bool
)—Defines whether the user can reorder theDataGridColumns
. The default value istrue
. -
ColumnReorderIndicatorTemplate
(DataTemplate
)—Defines the template that presents the indicator that is displayed between two columns during reordering. -
ColumnHeaderDragVisualTemplate
(DataTemplate
)—Specifies the template that presents the drag visual of the dragged column header.
Events
The TreeDataGrid inherits the following events related to the DataGrid reordering operation:
-
ColumnReorderStarting
—Raised when the user starts to drag a column to reorder it. TheColumnReorderStarting
event handler receives the following parameters:- A
sender
argument, which is of typeobject
, but can be cast to theRadDataGrid
type. - A
ColumnReorderStartingEventArgs
object, which has a reference to the following properties:-
Column
(DataGridColumn
)—Gets the column that will be reordered. -
Index
(int
) —Gets the index of the column that will be reordered. TheIndex
is the index of the item inside theFrozenColumns
orUnfrozenColumns
collection, depending on the value ofColumn.IsFrozen
. -
Cancel
(bool
)—Defines a value indicating whether the reordering operation is canceled.
-
- A
-
ColumnReordering
—Raised continuously while the column is being dragged. TheColumnReordering
event handler receives the following parameters:- A
sender
argument, which is of typeobject
, but can be cast to theRadDataGrid
type. - A
ColumnReorderingEventArgs
object, which has a reference to the following properties:-
Column
(DataGridColumn
)—Gets the column that will be reordered. -
OldIndex
(int
) —Gets the initial index of the column that is being reordered. TheOldIndex
is the old index of the item inside theFrozenColumns
orUnfrozenColumns
collection, depending on the value ofColumn.IsFrozen
. -
NewIndex
(int
) —Gets the new potential index of the column that is being reordered. TheNewIndex
is the new index of the item inside theFrozenColumns
orUnfrozenColumns
collection, depending on the value ofNewIsFrozen
. -
NewIsFrozen
(bool
)—Gets the new potentialTelerik.Maui.Controls.DataGrid.DataGridColumn.IsFrozen
value of the column that is being reordered. -
CanDrop
(bool
)—Defines a value indicating whether dropping the column at this specific location is allowed. The default value istrue
.
-
- A
-
ColumnReorderCompleting
—Raised when the user drops the column. This doesn't mean the column is reordered. TheColumnReorderCompleting
event handler receives the following parameters:- A
sender
argument, which is of typeobject
, but can be cast to theRadDataGrid
type. - A
ColumnReorderCompletingEventArgs
object, which has a reference to the following properties:-
Column
(DataGridColumn
)—Gets the column that is being reordered. -
OldIndex
(int
) —Gets the initial index of the column that is being reordered. TheOldIndex
is the old index of the item inside theFrozenColumns
orUnfrozenColumns
collection, depending on the value ofColumn.IsFrozen
. -
NewIndex
(int
) —Gets the new potential index of the column that is being reordered. TheNewIndex
is the new index of the item inside theFrozenColumns
orUnfrozenColumns
collection, depending on the value ofNewIsFrozen
. -
NewIsFrozen
(bool
)—Gets the new potentialTelerik.Maui.Controls.DataGrid.DataGridColumn.IsFrozen
value of the column that is being reordered. -
IsDropAllowed
(bool
)—Gets a value that indicates whether the column was dropped at a valid location. A valid location means that the column has changed its index and/or the value of itsIsFrozen
property and the drop at this location was not forbidden by setting theTelerik.Maui.Controls.DataGrid.ColumnReorderingEventArgs.CanDrop
property of theTelerik.Maui.Controls.DataGrid.ColumnReorderingEventArgs
tofalse
. The default value istrue
. -
Cancel
(bool
)—Defines a value indicating whether the reordering operation is canceled.
-
- A
-
ColumnReordered
—Raised when a column has been successfully reordered. TheColumnReordered
event handler receives the following parameters:- A
sender
argument which is of typeobject
, but can be cast to theRadDataGrid
type. - A
ColumnReorderCompletingEventArgs
object, which has a reference to the following properties:-
Column
(DataGridColumn
)—Gets the column that has been reordered. -
OldIndex
(int
) —Gets the initial index of the column that has been reordered. TheOldIndex
is the old index of the item inside theFrozenColumns
orUnfrozenColumns
collection, depending on the value ofOldIsFrozen
. -
OldIsFrozen
(bool
)—Gets the initialTelerik.Maui.Controls.DataGrid.DataGridColumn.IsFrozen
value of the column that has been reordered. -
NewIndex
(int
) —Gets the new index of the column that has been reordered. TheNewIndex
is the new index of the item inside theFrozenColumns
orUnfrozenColumns
collection, depending on the value ofColumn.IsFrozen
.
-
- A
As the TreeDataGrid inherits from DataGrid, ror the runnable example representing the Drag Templates, see the SDKBrowser Demo Application and go to DataGrid > Columns.