设置查询以搜索dojo datagrid的所有字段 [英] Set query to search all fields of a dojo datagrid

查看:208
本文介绍了设置查询以搜索dojo datagrid的所有字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Dojo DataGrid有几个字段。我正在设置查询,一次搜索一个字段,如下所示:

  grid.setQuery({name: Bob},{ignoreCase:true}); 

然而,我想要查询一次搜索所有的字段。例如说我有三个字段名为名字,朋友,家庭。假设我只想在三个字段中的任何一个中包含Bob的行显示在网格中。如果没有三个单独的查询,我该怎么做呢?



任何帮助都不胜感激。

解决方案

您的商店是否为 ItemFileReadStore QueryReadStore



如果ItemFileReadStore可能可以使用AndOrReadStore
http://dojotoolkit.org/reference-guide/dojox/data/AndOrReadStore.html



否则,对于有限的提取存储的最佳建议是调整后端代码以支持过滤选项,以便当存储进行POST(或GET)时,您将解析出一个您要搜索的字段,并相应地返回结果集。



你会看到像

 开始0 
count 25
columnsToQuery:[name,friend,family] //或者也可以是CSV字符串将
columnOperator:AND
columnValue:Bob

您必须根据业务需要调整范例,但只要服务器可以正常根据过滤输入返回结果集,这种方法将起作用。



生成此类请求的调用将是

  grid。 setQuery({
columnsToQuery:[name,friend,family],
columnOperator:AND,
columnValue:Bob
});


I have a Dojo DataGrid with several fields. I'm currently setting the query to search one field at a time, like so:

grid.setQuery( {name:"Bob"}, {ignoreCase:true} );

However I would like the query to search all the fields at once. For example say I have three fields titled "name", "friend", "family". Let's say I only want the rows that contain "Bob" in any of the three fields to show in the grid. How would I got about doing that without three separate queries?

Any help is appreciated.

解决方案

Is your store an ItemFileReadStore or a QueryReadStore?

If ItemFileReadStore you may be able to utilize the AndOrReadStore http://dojotoolkit.org/reference-guide/dojox/data/AndOrReadStore.html

Otherwise, my best suggestion for a limited fetch store would be to adjust your back-end code to support filtering options such that when the store makes a POST(or GET), you parse out an array of fields that you want to search against, and the result set is returned accordingly.

You'd see something like

start 0
count 25
columnsToQuery : ["name","friend","family"]  //or perhaps a CSV string will do
columnOperator : "AND"
columnValue : "Bob"

You'd have to adjust the paradigm as per your business needs, but as long as the server can properly return the result set based on the filtering inputs this approach will work.

The call to generate such a request would be

grid.setQuery({
  columnsToQuery : ["name","friend","family"],
  columnOperator : "AND",
  columnValue : "Bob"
});

这篇关于设置查询以搜索dojo datagrid的所有字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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