VSeed, an elegant data composer, transforming complexity into simplicity.
!!!###!!!title=search——VisActor/VTable tutorial documents!!!###!!!!!!###!!!description=The `@visactor/vtable-search` package is a component that encapsulates the VTable table search function. It supports searching the contents of cells and highlighting and jumping related search results.!!!###!!!
Search component
The @visactor/vtable-search package is a component that encapsulates the VTable table search function. It supports searching the contents of cells and highlighting and jumping related search results.
First, you need to install the @visactor/vtable and @visactor/vtable-search packages in your application, and then introduce them in your code to generate a table instance and a search component instance:
import * as VTable from '@visactor/vtable';
import { SearchComponent } from '@visactor/vtable-search';
//config option//......const tableInstance = new VTable.ListTable(option);
// search componentconst search = newSearchComponent({
table: tableInstance,
autoJump: true// Whether toautomaticallyjumptothefirstsearchresultafterthesearchiscompleted});
Start Search
The search component provides the search method, which is used to search the contents of cells, highlight and return search results:
highlightCellStyle and focusHighlightCellStyle are two different styles. The former is used to highlight all search results, and the latter is used to highlight the current target search results. Both styles take effect on the entire target cell of the search results. , currently does not support highlighting part of the text in the cell.
Component methods
search starts a search, receives a string, and returns an object containing the index of the current search result and a search result array. Each item of the search result array contains the column and row of the current search result, and the content of the current cell.
next & prev jumps to the search results and returns an object containing the index of the current search result and the search result array. Each item of the search result array contains the column and row of the current search result, as well as the content of the current cell.