@libregrid/find
v1.3.5
Published
Find for AG Grid Community — part of LibreGrid
Readme
@libregrid/find
Search cell text, highlight matches, and move between results without removing rows from the grid. Use filters when the goal is to narrow the displayed dataset.
Install
npm install "ag-grid-community@^36.2.0" @libregrid/findRequires ag-grid-community >=36.1.0 <37 as a peer dependency.
Usage
In a browser TypeScript project, add a grid container before running the code:
<div id="grid" style="height: 400px"></div>import { ModuleRegistry, AllCommunityModule, createGrid } from 'ag-grid-community';
import { FindModule } from '@libregrid/find';
ModuleRegistry.registerModules([AllCommunityModule, FindModule]);
const api = createGrid(document.querySelector<HTMLElement>('#grid')!, {
columnDefs: [{ field: 'country' }, { field: 'status' }],
rowData: [{ country: 'United Kingdom', status: 'Published' }],
findOptions: { caseSensitive: false },
});
api.setGridOption('findSearchValue', 'united');
api.addEventListener('findChanged', () => {
console.log(api.findGetTotalMatches(), 'matches');
});
api.findNext();
api.findPrevious();Customize what a column matches against with getFindText. This is useful
when the rendered value differs from the raw data:
{
field: 'status',
getFindText: ({ value }) => (value === 'Published' ? 'Live' : value == null ? null : String(value)),
}Return null from getFindText to exclude a cell from search entirely.
API
| Export | Purpose |
| ------------------ | ------------------------------------------------------------------------------ |
| FindModule | Registers the feature (moduleName: 'Find'). |
| FindService | Bean backing findSearchValue, findNext/findPrevious, and match tracking. |
| FindCellRenderer | Wraps a cell's rendered output to highlight matches. |
Learn more
- LibreGrid README — full package list and quick start
@libregrid/advanced-filter— filter rows out entirely rather than highlighting matches
Angular
Use the same column definitions and grid options with ag-grid-angular.
Register the modules shown above through provideLibreGrid from
@libregrid/angular. See the
Angular setup for a complete component and bootstrap example.
License
MIT — see LICENSE and NOTICE. LibreGrid is an independent project and is not affiliated with, endorsed by, or sponsored by AG Grid Ltd.
