After a Click hold and drag to select multiple rows
opened this issue · comments
Deleted user commented
After a Click hold and drag to select multiple rows, what event could be called to get the selected rows when mouse is released?
Manki Kim commented
See the example below to get the rows being dragged.
class EmptyScreen extends StatefulWidget {
static const routeName = 'empty';
const EmptyScreen({Key? key}) : super(key: key);
@override
_EmptyScreenState createState() => _EmptyScreenState();
}
class _EmptyScreenState extends State<EmptyScreen> {
late List<PlutoColumn> columns;
late List<PlutoRow> rows;
late PlutoGridStateManager stateManager;
late StreamSubscription eventStream;
@override
void dispose() {
eventStream.cancel();
super.dispose();
}
@override
void initState() {
super.initState();
columns = [
PlutoColumn(
title: 'column1',
field: 'column1',
type: PlutoColumnType.text(),
enableRowDrag: true,
renderer: (rendererContext) {
return Text(
rendererContext.cell.value,
maxLines: 2,
);
},
),
PlutoColumn(
title: 'column2',
field: 'column2',
type: PlutoColumnType.number(),
backgroundColor: Colors.blue,
),
PlutoColumn(
title: 'column3',
field: 'column3',
type: PlutoColumnType.number(),
),
];
rows = DummyData.rowsByColumns(length: 30, columns: columns);
}
void streamListeners(PlutoGridEvent event) {
if (event is PlutoGridDragRowsEvent) {
print('dragging');
print(event.targetIdx);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
padding: const EdgeInsets.all(15),
child: PlutoGrid(
columns: columns,
rows: rows,
onChanged: (PlutoGridOnChangedEvent event) {
print(event);
},
onLoaded: (PlutoGridOnLoadedEvent event) {
stateManager = event.stateManager;
stateManager.setSelectingMode(PlutoGridSelectingMode.row);
eventStream = stateManager.eventManager!.listener(streamListeners);
},
configuration: const PlutoGridConfiguration(
enterKeyAction: PlutoGridEnterKeyAction.editingAndMoveDown,
),
),
),
);
}
}
github-actions commented
This issue is stale because it has been open for 30 days with no activity.
github-actions commented
This issue was closed because it has been inactive for 14 days since being marked as stale.