搜索时执行完全匹配 [英] Perform exact match when searching

查看:199
本文介绍了搜索时执行完全匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站,我使用插件 wpDataTables ,基于 jQuery DataTables

On my site I am using the plugin wpDataTables based on jQuery DataTables.

价目表中第一列包含值 - AUR D DH 等等。表被编程为仅显示许多的前6个结果。

My first column in the price list table contains values - AUR, D, DH, etc. Table is programmed to show only first 6 results out of many.

这是问题:如果我希望用户在搜索字段 D 中找到值 D 和用户类型,您将得到一个列表中的值 DH

Here is the problem: If I want user to find value D and user types in the search field D, you'll get a list with values DH.

这是因为默认情况下,jQuery DataTables插件查找包含值 D (例如 DH 等),但我希望它执行完全匹配。

It happens because by default jQuery DataTables plugin finds records that contain value D (such as DH, etc), but I want it to perform exact match.

请参阅 Excel电子表格,其中包含所有记录作为参考。

Please see Excel spreadsheet containing all records for reference.

推荐答案

您需要遵循此文档,最终得到以下内容:

You need to follow this documentation and end up with something like this:

table.column( 1 ).search( '^My exact match$', true, false );

您可以在传递到搜索功能之前输入或添加引号时使用引号:

You can also use quotes when you input or add them before passing to the search function:

 table.search( '"My exact match"' );

文档: https://datatables.net/reference/api/column().search()

这篇关于搜索时执行完全匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆