Set query to search all fields of a dojo datagrid

我是研究僧i 提交于 2019-12-07 05:47:44

问题


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.


回答1:


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"
});


来源:https://stackoverflow.com/questions/7034911/set-query-to-search-all-fields-of-a-dojo-datagrid

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