Using JS to implement table multi-conditional fuzzy query, which is compatible with paging

Source: Internet
Author: User

The requirements are as follows:

Realize the name, position, direct superior, user type four conditions fuzzy query, the results of the query to the page display.

Implementation logic:

Defines two arrays, where vm.nowalluserlists is the original data. Vm.nowalluserfilter is the filtered data. The final loop Vm.nowalluserfilter to render the table.

Before filtering, assign the value of Vm.nowalluserlists to Vm.nowalluserfilter, and the table renders all the data.

When filtering, initialize Vm.nowalluserfilter to an empty array and push the filtered contents into the array. The table renders the filtered data at this time.

Because it is not case-sensitive, you need to convert the filter criteria and the filtered data contents to uppercase toUpperCase.

The four filter conditions are the same as the relationship, then the && is connected.

The specific code is as follows:

If it is a single-condition query and a single-page query (without paging), there is an easier way. Most of the online circulation is also this, as follows:

$("table tbody tr").stop().hide() //将tbody中的tr都隐藏

   .filter(":contains(‘"+($(this).val())+"‘)").show();//将查询到相关内容的tr显示

Using JS to implement table multi-conditional fuzzy query, which is compatible with paging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.