Ashish Shrestha
Ashish Shrestha

Reputation: 1

Ag-Grid Vue js Filter

Need one help please. I am using Ag Grid in Vue js.... have a situation where i need to turn off the checkbox in filter on load initially so that the grid wont show the records at the beginning. Is it possible?

For eg in the below link(screenshot) , I need to uncheck the "Completed" status on load and the grid wont show the records with "Completed" status.

Any help would be highly appreciated ...Thanks

Screenshot

Upvotes: 0

Views: 442

Answers (1)

un.spike
un.spike

Reputation: 5113

You can execute setFilterModel on firstDataRendered event

(firstDataRendered)="onFirstDataRendered($event)"


onFirstDataRendered(params){
    this.preDefinedFilter();
}

preDefinedFilter(){
    let hardcodedFilter = {
        // 'status' - field name with 'filter: "agSetColumnFilter"' difinition in colDef
        // list of statuses which will be displayed
        status: ["Uncompleted", "Error", "Whatever"]
    };

    this.gridApi.setFilterModel(hardcodedFilter);
    this.gridApi.onFilterChanged();
}

Demo

don't blame me, the sample written on angular but I suppose it wouldn't be hard to adapt the solution.

Upvotes: 1

Related Questions