- 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 rangeand this will clear any existing selected cells/ranges -
Ctrl + Mouse drag- HoldingCtrandMouse dragwill selectmultiple cell rangesand 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
cellIdSplitByis_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
truein this object, it will have a selected state
The following values are provided to the table instance:
-
state.selectedCellIds: Object<cellId: Boolean(true)>selectedCellIdsis 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. NowselectedCellIdscontains all cell Ids except the cell Ids which fall undercurrently selecting
-
state.currentSelectedCellIds: Object<cellId: Boolean(true)>currentSelectedCellIdsis 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. NowcurrentSelectedCellIdsis a state which containscurrently selectingcell Ids - Once user ends selection,
currentSelectedCellIdsare 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
selectedCellIdsstate
- 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
selectedCellIdsviasetSelectedCellIds. More info and demo available in thecell-range-selectionexample
- 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