0
votes

I try to filter the ag-grid by using a select box. The grid definition is:

<ag-grid-vue id="myGrid" style="width: 1140px; height:500px"

   class="ag-theme-balham"
   :columnDefs="columnDefs"
   :rowData="rowData"
   :enableSorting="true"
   :enableFilter="true"
   :pagination="true"
   :paginationPageSize="10"                                    
   :setQuickFilter="quickFilterText"
</ag-grid-vue>

Data Part is :

data() {
            return {
                columnDefs: null,
                rowData: null,
                quickFilterText: ''
     }

and i try to capture the value of select box on watch in Vue:

watch: {

    filter: {
        handler: function (filter) {
            {
                this.$nextTick(() => {
                    let companyNames = this.$refs.company.getSelectedValue();
                    this.quickFilterText = companyNames;
                    gridOptions.api.setQuickFilter(this.quickFilterText);
                    document.addEventListener('DOMContentLoaded', function() {
                        let gridDiv = document.querySelector('#myGrid');
                        new agGrid.Grid(gridDiv, gridOptions);
                    });
                });
            }
        },
        deep: true
    }
},

after i select in select box then i see the error:

"TypeError: Cannot read property 'setQuickFilter' of undefined"

any one can help me? thank you

1
can you share your data properties? where is this gridOptions coming from?waleed ali
this is my data part: data() { return { columnDefs: null, rowData: null, quickFilterText: '', }Shirin
where are you declaring and initializing gridOptions? The problem is with it's initialization, because it's property api is undefinedwaleed ali
Oh you mean i need to declare separate because i taught when we define in <ag-grid-vue> is enoughShirin

1 Answers

1
votes

Check this post

You need to use gridReady function to bind gridApi to the local property.

Once you will bind it, you would be able to use this.gridApi.setQuickFilter(this.quickFilterText);