SpreadJS Documentation > Developer's Guide > Managing the User Interface > Working with Selections |
You can select cells, rows, columns, or multiple ranges in the widget.
Click and drag with the left mouse button to select a block of cells, columns, or rows. You can use the mouse click and Ctrl key to select multiple ranges of cells. Navigation keys are listed in Using Keyboard Navigation.
You can specify the type of selection unit (cell, column, or row) with the selectionUnit method. You can specify the range of the selection (single, range, or multiple range) with the selectionPolicy method.
You can set the selection color and border with the selectionBackColor and selectionBorderColor methods. You can use standard colors and theme colors.
This example selects a range of cells.
JavaScript |
Copy Code
|
---|---|
activeSheet.addSelection(4, 0, 2, 2); //activeSheet.clearSelection(); var sels = activeSheet.getSelections(); alert(sels.length); |
This example allows single row or block row selection.
JavaScript |
Copy Code
|
---|---|
activeSheet.selectionUnit(GcSpread.Sheets.SelectionUnit.Row); activeSheet.selectionPolicy(GcSpread.Sheets.SelectionPolicy.Range); |
This example sets the color for the selected area and border.
JavaScript |
Copy Code
|
---|---|
activeSheet.selectionBackColor("Accent 6"); activeSheet.selectionBorderColor("Accent 1") |