Table filter getting reset vue js

149 Views Asked by At

I have filters for each column in my table and the filter works fine when i type in for one column and when i filter another column in parallel, the results shows only for the second filter (means the first filter i typed is getting igonored). Always the latest filter works.

//computed

filteredList: function () {
         
            var vm = this.vm;
            var columnFilters = this.columnFilters;
            var list = [...this.vm.entries];
            var search, value;

            var filteredIndexes = Object.keys(this.columnFilters);
            if (filteredIndexes.length > 0) {
                filteredIndexes.forEach(function (index) {
                   
                    if (columnFilters[index] != '') {
                       
                        list = vm.entries.filter(function (row) {
                           
                            search = columnFilters[index].toLowerCase();
                             value = row.rowItems[index].itemDisplay.toLowerCase();
                            return value.includes(search);
                        });
                    }
                });
              
            } 
             return list;
        },

Where i'm going wrong?

0

There are 0 best solutions below