Autofill
AutoFillPlugin
The AutoFillPlugin
enhances RevoGrid with advanced autofill capabilities,
allowing users to automatically fill cell ranges based on various sequence
strategies. This plugin supports numeric, date, and text sequences, making it
versatile for different data types and user needs.
Features:
- Utilizes multiple pre-defined strategies: linear numeric sequences, date sequences with and without intervals, and text sequences.
- Listens for the
beforeautofill
to trigger autofill actions based on user interactions. - Allows registration of additional custom autofill strategies.
- Applies autofilled data directly to the grid, updating the data store efficiently.
Usage:
- Import
AutoFillPlugin
and add it to the RevoGrid’s plugin list. - The grid will automatically handle range selection and autofilling based on the registered strategies.
Example
import { AutoFillPlugin } from '@revolist/revogrid-pro'
const grid = document.createElement('revo-grid');grid.plugins = [AutoFillPlugin]; // Add autofill functionality to the grid
This plugin is ideal for enhancing user productivity in data entry tasks by providing intelligent filling of repetitive or sequential data patterns, commonly used in spreadsheets and data management applications.
class AutoFillPlugin { /** * Register a new autofill strategy */ registerStrategy(strategy: AutoFillStrategy);}
AutoFillDirection
export type AutoFillDirection = 'both';
AutoFillStrategy
export type AutoFillStrategy = ( selectedData: any[][], direction: AutoFillDirection, newRange: RangeArea) => any[][] | null;
linearNumericSequenceStrategy
The linearNumericSequenceStrategy
is an autofill strategy for RevoGrid’s
AutoFillPlugin designed to generate numeric sequences with a constant interval.
This strategy is ideal for filling grid cells with linear numeric progressions.
Features:
- Validates that all selected data elements are numeric, filtering out non-numeric sequences to prevent errors.
- Computes the common difference between numbers in the sequence to establish a consistent interval.
- Extends the numeric sequence across the specified range, maintaining the calculated interval throughout the grid.
- Supports dynamic autofill in both horizontal and vertical directions.
Usage:
- Import
linearNumericSequenceStrategy
and register it with the AutoFillPlugin for use in RevoGrid to enable linear numeric autofill functionality.
Example
import { linearNumericSequenceStrategy } from '@revolist/revogrid-pro'
const grid = document.createElement('revo-grid');grid.plugins = [AutoFillPlugin];AutoFillPlugin.registerStrategy(linearNumericSequenceStrategy); // Register strategy
This strategy is particularly suited for applications requiring predictable numeric data entry, such as financial models, inventory lists, or any scenario where arithmetic progression is needed.
linearNumericSequenceStrategy: AutoFillStrategy;
dateSequenceStrategy
The dateSequenceStrategy
is an autofill strategy designed for RevoGrid’s
AutoFillPlugin, which facilitates the automatic generation of consistent date
sequences within grid cells. This strategy is used to extend a selected range
of date values either as Date objects or ISO date strings.
Features:
- Validates that all selected data elements are either Date objects or valid ISO date strings, ensuring consistency in input types.
- Computes the common difference between consecutive dates to determine the sequence’s interval.
- Generates a new date sequence extending the original, maintaining the identified interval across the target range specified.
- Supports output as either Date objects or ‘YYYY-MM-DD’ formatted strings, depending on the input type.
Usage:
- Import
dateSequenceStrategy
and register it with the AutoFillPlugin for use in RevoGrid to enable date autofill functionality.
Example
import { dateSequenceStrategy } from '@revolist/revogrid-pro'
const grid = document.createElement('revo-grid');grid.plugins = [AutoFillPlugin];AutoFillPlugin.registerStrategy(dateSequenceStrategy); // Register date sequence strategy
This strategy is ideal for applications dealing with chronological data entry, where users benefit from automatic date progression, such as scheduling tools or timeline management systems.
dateSequenceStrategy: AutoFillStrategy;
dateSequenceWithIntervalStrategy
The dateSequenceWithIntervalStrategy
is an advanced autofill strategy for
RevoGrid’s AutoFillPlugin that facilitates filling grids with date sequences
that maintain a consistent interval. It extends upon basic date sequence
strategies by using a defined interval between consecutive dates.
Features:
- Validates that input data consists of either Date objects or ISO date strings.
- Ensures consistency in date intervals across the sequence, filtering out inconsistent sequences.
- Generates a date sequence extending beyond the initial selection, maintaining the calculated interval throughout the target range.
- Supports output in both Date objects and ‘YYYY-MM-DD’ strings, based on input type.
Usage:
- Import
dateSequenceWithIntervalStrategy
and register it with the AutoFillPlugin to enable interval-based date autofill in RevoGrid.
Example
import { dateSequenceWithIntervalStrategy } from '@revolist/revogrid-pro'
const grid = document.createElement('revo-grid');grid.plugins = [AutoFillPlugin];AutoFillPlugin.registerStrategy(dateSequenceWithIntervalStrategy); // Register strategy
This strategy is particularly useful for applications that require consistent scheduling or timeline management, where maintaining a regular interval between dates is essential for data accuracy and usability.
dateSequenceWithIntervalStrategy: AutoFillStrategy;
textSequenceStrategy
textSequenceStrategy: AutoFillStrategy;