allowColumnsDragging property

bool allowColumnsDragging
final

Decides whether the column can be dragged and dropped to the required position.

Columns will not be automatically reordered from one position to another position. You must use the SfDataGrid.onColumnDragging callback. For this, you must maintain the columns in variable and assign to SfDataGrid.columns property. Then, you can reorder a column in the collection inside the setState method through SfDataGrid.onColumnDragging callback.

Defaults to false.

The following example shows how to reorder the columns,

See also,

Implementation

// @override
// Widget build(BuildContext context) {
//   return Scaffold(
//     appBar: AppBar(
//       title: const Text('Syncfusion Flutter DataGrid'),
//     ),
//     body: SfDataGrid(
//       columns: columns,
//       source: employeeDataSource,
//       allowColumnsDragging: true,
//       onColumnDragging: (DataGridColumnDragDetails details) {
//         if (details.action == DataGridColumnDragAction. dropping) {
//           setState(() {
//             final GridColumn dragColumn = columns[details.from];
//             columns[details.from] = columns[details.to];
//             columns[details.to] = dragColumn;
//           });
//         }
//         return true;
//       },
//     ),
//   );
// }
///
/// See also,
///
/// * [SfDataGrid.onColumnDragging] - Used to reorder a column from one position to another position.
/// * [SfDataGrid.columnDragFeedbackBuilder] - Used to show any widget under the pointer when a drag is under way.
final bool allowColumnsDragging;