Dojo dgrid Filter
Creating a simple textbox that live-filters your dgrid is not super-obvious though. Here’s how.
First you must understand how dstore and dgrid work together. Here’s a summary:
dstore provides a common API for accessing and manipulating data. It is intended to replace dojo/store and the older dojo/data API. Starting with 0.4 dgrid interfaces directly with dstore stores. Previous releases of dgrid worked with dojo/store instances, and the older dojox/grid works with the older dojo/data API.
In other words, to filter the dgrid, just filter the dstore that drives it.
First, create your dstore and dgrid. Then wire up your TextBox to call a function on every keypress:
Then write your function. Here you want to go through all the grid columns, creating a Filter on each one, and apply them to the dstore. Finally, set the dstore’s filter to the new Filter you created:
I periodically write about technology, maps, open data, and other software topics. To get updates about new posts: