如何在多列上查询dgrid [英] How to query a dgrid on multiple columns

查看:116
本文介绍了如何在多列上查询dgrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建一个dgrid查询,以便在多个列上搜索正则表达式字符串?通常语法指定{column1:foo,column2:foo},但是会查找column1和column2都是foo的行。但是我想对两列使用相同的搜索字符串...这是可能的,我该怎么办?我需要像{column1 || column2:foo}。

Is it possible to create a dgrid query that will search for a regex string on more than one column? Usually the syntax specifies {column1: "foo", column2: "foo"} but that will look for rows where both column1 AND column2 are "foo". But I want to use the same search string against both columns... is that possible and how would I do it? I need something like {column1 || column2 : "foo"}.

推荐答案

你可以在我的回答中提到你自己的功能, HREF =https://stackoverflow.com/questions/12010731/is-it-possible-to-filter-data-in-a-dgrid-like-you-can-in-a-datagrid-if-so-how >是否可以像在datagrid中一样在dgrid中过滤数据?

You can write your own function as I mentioned in my answer to your previous question Is it possible to filter data in a dgrid like you can in a datagrid?

或者您可以使用资源查询语言(RQL)

dgrid 查询其商店,例如默认情况下使用 dojo / store / util / SimpleQueryEngine dojo / store / Memory 您所需要做的就是将 store.queryEngine 属性与您选择的 QueryEngine 一起提供。在RQL的情况下,它看起来像这样():

dgrid queries its store, e.g. dojo/store/Memory, which uses dojo/store/util/SimpleQueryEngine by default. All you need to do is to feed store.queryEngine property with QueryEngine of your choice. In the case of RQL, it looks like this (source):

require(["dojo/store/Memory", "rql/js-array", "dgrid/OnDemandGrid"], function(Memory, rql, Grid) {

    var store = new Memory({ data: { /* some data here */}});
    store.queryEngine = rql.query;

    var grid = new Grid({
        store: store,
        columns: { /* some columns here */}
    }, "grid")

});

现在,您可以使用RQL语法查询dgrid。查询以回答您的问题:(column1 = foo | column2 = foo)

Now you can query dgrid with RQL syntax. The query to answer your question: (column1=foo|column2=foo).

请看看我的jsFiddle( http://jsfiddle.net/phusick/VjJBT )。随意使用dgrid本身(有一些预定义的查询)或使用DOH单元测试(打开JS控制台查看输出)进行分叉和实验:

Please have a look at my jsFiddle (http://jsfiddle.net/phusick/VjJBT). Feel free to fork and experiment either with dgrid itself (there are some predefined queries) or with DOH unit tests (open JS console to see an output):

这篇关于如何在多列上查询dgrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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