如何在单列搜索框中搜索2列? [英] How to search in 2 columns with single search box?

查看:131
本文介绍了如何在单列搜索框中搜索2列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我想通过名称和电子邮件在dgrid中找到。到目前为止,我只能通过名称搜索。我使用以下内容:

  dgrid.set(query,{name:new RegExp(searchKeyword,'i')} ); 

如何修改,以便我可以通过姓名和电子邮件进行搜索?



jsFiddle

解决方案

dojo / store / Memory 之后的查询引擎(称为 dojo / store / util / SimpleQueryEngine )不支持 OR 操作,这意味着它不能查询所有记录:

 名称匹配searchterm或电子邮件匹配searchterm 

要解决这个问题,您将不得不使用不同的查询引擎比默认的。目前Dojo中没有其他查询引擎可用,但是有一个名为资源查询语言的独立项目。您应该检查此答案和图书馆本身在 Github


In my project, I would like to find by name and email in the dgrid. As of now, I am able to search by name only. I used the following:

dgrid.set("query", {name: new RegExp(searchKeyword, 'i')});

How do I modify this so that I can search by both, name AND email?

jsFiddle

解决方案

The querying engine behind a dojo/store/Memory (called dojo/store/util/SimpleQueryEngine) does not support OR operations, which means it can't query all records where:

name matches searchterm OR email matches searchterm

To solve that issue you will have to use a different query engine than the default one. Currently there are no other query engines available in Dojo but there is a standalone project called the resource query language. You should check this answer and the library itself on Github.

这篇关于如何在单列搜索框中搜索2列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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