When working with a Range Selection, a Fill Handle allows you to run operations on cells as you adjust the size of the range.
To enable the Fill Handle, simply set enableFillHandle to true in the gridOptions as shown below:
const gridOptions = {
columnDefs: [
{ field: 'country' },
{ field: 'year' },
{ field: 'sport' },
{ field: 'total' }
],
enableRangeSelection: true,
enableFillHandle: true,
// other grid options ...
}It's important to note that if you enable both enableFillHandle and enableRangeHandle, the Fill Handle will take precedence.
The default Fill Handle behaviour will be as close as possible to other spreadsheet applications. Note the following:
null).Reducing a range selection with the Fill Handle will clear cell contents by default, as can be observed in the Range Reduction example above.
If this behaviour for decreasing selection needs to be prevented, the flag suppressClearOnFillReduction should be set to true.
By the default, the Fill Handle can be dragged horizontally or vertically. If dragging only vertically, or only horizontally is a requirement, the gridOptions property fillHandleDirection property can be set or set via the API using setFillHandleDirection. This default value is xy.
const gridOptions = {
columnDefs: [
{ field: 'country' },
{ field: 'year' },
{ field: 'sport' },
{ field: 'total' }
],
enableRangeSelection: true,
enableFillHandle: true,
fillHandleDirection: 'x',
// other grid options ...
}Often there is a need to use a custom method to fill values instead of simply copying values or increasing number values using linear progression. In these scenarios, the fillOperation callback should be used.
const gridOptions = {
columnDefs: [
{ field: 'country' },
{ field: 'year' },
{ field: 'sport' },
{ field: 'total' }
],
enableRangeSelection: true,
enableFillHandle: true,
fillOperation: (fillOperationParams) => {
return 'Foo';
},
// other grid options ...
}Properties available on the FillOperationParams<TData = any, TContext = any> interface.
eventTypeMouseEvent | The mouse event for the fill operation. |
valuesTypeany[] | The values that have been processed by the fill operation. |
row | The RowNode of the current cell being changed. |
columnTypeColumn | The Column of the current cell being changed. |
initial | The values that were present before processing started. |
current | The index of the current processed value. |
current | The value of the cell being currently processed by the Fill Operation. |
directionType'up' | 'down' | 'left' | 'right' | The direction of the Fill Operation. |
apiTypeGridApi | The grid api. |
column | The column api. |
contextTypeTContext | Application context as set on gridOptions.context. |
If a fillOperation callback is provided, the fill handle will always run it. If the current values are not relevant to the fillOperation function that was provided, false should be returned to allow the grid to process the values as it normally would.
The example below will use the custom fillOperation for the Day of the week column, but it will use the default operation for any other column.
The example below will use the custom fillOperation to prevent values in the Country column from being altered by the Fill Handle.
When the fillOperation function returns params.currentCellValue that value is not added to the params.values list. This allows users to skip any cells in the Fill Handle operation.
Non editable cells will not be changed by the Fill Handle, so there is no need to add custom logic to skip columns that aren't editable.
When the grid is in Read Only Edit mode the Fill Handle will not update the data inside the grid. Instead the grid fires cellEditRequest events allowing the application to process the update request.
The example below will show how to update cell value combining the Fill Handle with readOnlyEdit=true.
The Fill Handle can be disabled on a per column basis by setting the column definition property suppressFillHandle to true .
In the example below, please note that the Fill Handle is disabled in the Country and Date columns.