Add a method to reset(null) the value of the selection column.
In the case of the selection column, values other than items are not changed.
Currently, you can change the value in the following way.
stateManager.currentCell.value = '';
stateManager.notifyListeners();
I will add a method to reset the value later.
And changing the value is as follows.
// For force, the default is false.
// This is when the mode of the grid is select,
// only the row can be selected and the value cannot be modified.
// In this case, the value can be forcibly modified.
stateManager.changeCellValue(stateManager.currentCell.key, null, force: true);
Originally posted by @bosskmk in https://github.com/bosskmk/pluto_grid/discussions/129#discussioncomment-292111
I've achieved something more user-friendly, allowing using a keyboard shortcut (supr) + adding an empty value (null) to my select items parameter:
// Add null to the list of valid items
var items = [null]..addAll(computedItems);
...
PlutoGrid(
onLoaded: (PlutoGridOnLoadedEvent event) {
stateManager = event.stateManager;
removeKeyboardListener = stateManager!
.keyManager!.subject.stream
// Keyboard listener
.listen(handleKeyboard);
stateManager!
.setSelectingMode(PlutoGridSelectingMode.none);
},
...
// Column definition
PlutoColumn(
title: 'Nullable column',
field: 'columnId',
type: PlutoColumnType.select(items)),
...
// Keyboard listener to delete values
void handleKeyboard(PlutoKeyManagerEvent event) {
// Specify the desired shortcut key.
var currentCell = stateManager?.currentCell;
if (currentCell != null) {
if (event.isKeyDownEvent) {
// On SUPR
if (event.event.logicalKey == LogicalKeyboardKey.delete) {
var column = stateManager?.currentColumn?.field;
if (column == 'columnId') {
// Empty the cell
currentCell.value = '';
stateManager!.notifyListeners();
}
}
}
}
}
It could be great to have something like this when a default PlutoGrid is created (using, of course, the wanted new "reset(null)" method you said.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.