Search supports secondary query or global query

Search function: https://blog.csdn.net/bbs11007/article/details/110948483

 

Often encountered when searching cannot be global, or searching for the first time, can not query again on the basis of search processing results

1. Focus on a few points, that is, global search to obtain global data

2. The search query data and the displayed data cannot be stored in one place

 //把所有数据给它,this.pages1.values是在表格中的所有数据
this.allpageValues =  this.pages1.values


let result = this.allpageValues.filter(row => {//this.allpageValues这个是表内所有数据
              //搜索那列的内容,这里搜索name、id等列的内容
             return row.name.indexOf(this.search1.toUpperCase()) > -1 
                || row.id.indexOf(this.search1.toUpperCase()) > -1 
                || row.code.indexOf(this.search1.toUpperCase()) > -1 
                || row.note.indexOf(this.search1.toUpperCase()) > -1;
            });
            //重新设置表格数据
            this.pages1.values = result ; //把搜索出来的展示出来,this.pages1.values这个被替换,所有不支持第二次全局搜索。
            console.log("搜索结果:",result);

Mainly pay attention to this.allpageValues.filter(row => {(this is all data query) and this.pages1.values ​​= result; (this is the data displayed by the query) can not be repeated, so as not to be able to perform a second query

Guess you like

Origin blog.csdn.net/bbs11007/article/details/112603656