- Plugin Hook
- Optional
useCellRangeSelection
is the hook that allows cell selection and cell range selection.
-
Mouse drag
- Click the mouse and drag to select acell range
and this will clear any existing selected cells/ranges -
Ctrl + Mouse drag
- HoldingCtr
andMouse drag
will selectmultiple cell ranges
and this keeps all existing selected cells/ranges -
Ctrl + click
- For cell selection and this keeps all existing selected cells/ranges
The following options are supported via the main options object passed to useTable(options)
cellIdSplitBy: String
- Optional
- This string is used to overwrite cell Id as
column Id + cellIdSplitBy + row Id
- By default
cellIdSplitBy
is_col_row_
where cell Id's are generated ascolumn Id + '_col_row_' + row Id
initialState.selectedCellIds: Object<cellId: Boolean>
- Optional
- Defaults to
{}
- If a cell's ID is set to
true
in this object, it will have a selected state
The following values are provided to the table instance
:
-
state.selectedCellIds: Object<cellId: Boolean(true)>
selectedCellIds
is a state that contains all selected cell Ids except current selecting range, once current selecting range is finished it moves toselectedCellIds
- More info: User performs range selection as
start selection
->currently selecting
->end selection
. NowselectedCellIds
contains all cell Ids except the cell Ids which fall undercurrently selecting
-
state.currentSelectedCellIds: Object<cellId: Boolean(true)>
currentSelectedCellIds
is a state that contains cell Ids ofcurrently selecting range
. It is a state when user is currently performing range selection- More info: User performs range selection as
start selection
->currently selecting
->end selection
. NowcurrentSelectedCellIds
is a state which containscurrently selecting
cell Ids - Once user ends selection,
currentSelectedCellIds
are moved tostate.selectedCellIds
, It is handled by hook itself
-
state.isSelectingCells: Boolean
- State which tells whether user is performing range selection
- Defaults to false
-
cellsById: Object<cellId: cell>
- This Object map has mapping of cell Id to it's cell instance
- Can be used to get cell value to further make any calculations. (for example: Finding average value of selected cells)
- This Object map has mapping of cell Id to it's cell instance
-
setSelectedCellIds: Function( Object<cellId: Boolean> )
- Use this function to set
selectedCellIds
state
- Use this function to set
-
getCellsBetweenId: Function( startCellId, endCellId ) => Object<cellId: Boolean(true)>
- This function is used to get all cells between start cell Id and end cell Id
- This is helpful when getting all cells that falls under a specific range and then setState
selectedCellIds
viasetSelectedCellIds
. More info and demo available in thecell-range-selection
example
- This is helpful when getting all cells that falls under a specific range and then setState
- This function is used to get all cells between start cell Id and end cell Id