搜索时执行完全匹配

编程入门 行业动态 更新时间:2024-10-28 12:23:04
本文介绍了搜索时执行完全匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的网站,我使用插件 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"' );

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

更多推荐

搜索时执行完全匹配

本文发布于:2023-10-26 09:14:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1529729.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!