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"
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With