How to query a dgrid on multiple columns

帅比萌擦擦* 提交于 2019-12-01 00:24:01
phusick

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):

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!