Toggle between Row Selection and Cell Selection
How do you toggle between row selection and cell selection modes?
GOAL:
I'd like to switch to:
A. "single-cell" mode when a cell is clicked.
B. "single-row" mode when a row's selector is clicked.
EXPLANATION:
There are a few things to keep in mind.
1. Grid Selector Events
Grid selection is triggered by Mouse events. Use the setSelectionMode method to switch between "single-cell" and "single-row" modes.
2. Deselect Rows
Before switching between "single-cell" and "single-row" selection modes, the selected rows and columns need to be deselected (or unselected... pick your favorite term). Use the setSelectedRows and setSelectedColumns to deselect any rows that are selected.
GOAL:
I'd like to switch to:
A. "single-cell" mode when a cell is clicked.
B. "single-row" mode when a row's selector is clicked.
EXPLANATION:
There are a few things to keep in mind.
1. Grid Selector Events
Grid selection is triggered by Mouse events. Use the setSelectionMode method to switch between "single-cell" and "single-row" modes.
2. Deselect Rows
Before switching between "single-cell" and "single-row" selection modes, the selected rows and columns need to be deselected (or unselected... pick your favorite term). Use the setSelectedRows and setSelectedColumns to deselect any rows that are selected.
obj.onCellMouseDown = function(event, column, row) {
if (this.getSelectionMode() != "single-cell") {
this.setSelectedColumns([]); // deselect any selected columns...
this.setSelectedRows([]); // deselect any selected rows...
this.setSelectionMode("single-cell");
}
};
obj.onSelectorMouseDown = function(event, index) {
if (this.getSelectionMode() != "single-row") {
this.setSelectedColumns([]); // deselect any selected columns...
this.setSelectedRows([]); // deselect any selected rows...
this.setSelectionMode("single-row");
}
};
ArdMan
April 20,