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"}.
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?
Or you can use Resource Query Language (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")
});
Now you can query dgrid with RQL syntax. The query to answer your question: (column1=foo|column2=foo)
.
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):
© 2022 - 2024 — McMap. All rights reserved.