Skip to content

Commit

Permalink
feat: Add setFilterModel.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gervwyk committed Apr 8, 2022
1 parent d0e425b commit 1c3d3f4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ The block types are hosted at:
- `autoSize`: When called, auto size columns. The following can be passed as the first argument of `args`.
- `skipHeader: boolean`: Do not consider header content width when auto-sizing columns.
- `columnIds: string[]`: List of `colId`s for which to calculate auto-size when called.
- `setFilterModel`: When called, apply filter model to table. See https://www.ag-grid.com/javascript-data-grid/filter-api/ for model details.

### AgGridAlpine Example

Expand Down
6 changes: 5 additions & 1 deletion src/AgGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ class AgGrid extends React.Component {
this.gridApi.exportDataAsCsv(args)
);
this.props.methods.registerMethod('sizeColumnsToFit', () => this.gridApi.sizeColumnsToFit());
this.props.methods.registerMethod('autoSize', ({ skipHeader, colIds }) => {
this.props.methods.registerMethod('setFilterModel', (model) =>
this.gridApi.setFilterModel(model)
);
this.props.methods.registerMethod('autoSize', (args = {}) => {
const { skipHeader, colIds } = args;
const allColumnIds = colIds || [];
if (!colIds) {
this.gridColumnApi.getAllColumns().forEach((column) => {
Expand Down
6 changes: 5 additions & 1 deletion src/AgGridInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ class AgGridInput extends React.Component {
this.gridApi.exportDataAsCsv(args)
);
this.props.methods.registerMethod('sizeColumnsToFit', () => this.gridApi.sizeColumnsToFit());
this.props.methods.registerMethod('autoSize', ({ skipHeader, colIds }) => {
this.props.methods.registerMethod('setFilterModel', (model) =>
this.gridApi.setFilterModel(model)
);
this.props.methods.registerMethod('autoSize', (args = {}) => {
const { skipHeader, colIds } = args;
const allColumnIds = colIds || [];
if (!colIds) {
this.gridColumnApi.getAllColumns().forEach((column) => {
Expand Down

0 comments on commit 1c3d3f4

Please sign in to comment.