I have some problems getting the custom formated JSON data into a dijit.form.FilteringSelect. It might be that this is the same for other types of dijit select boxes.
update:
One difference when using a FilteringSelect instead of a ComboBox is that validation errors
ar now shown on the element. All input is returning an “invalid value” tooltip.
Here is some sample JSON wich is returned from a database via PHP converted from
an result array:
{"animals":[
{"gr_id":"1","gr_name":"Dog","gr_description":null},
{"gr_id":"4","gr_name":"Cat","gr_description":null}]}
Here is the HTML code for displaying the combo box and defining the store:
<div dojoType="dojox.data.QueryReadStore" url="getAnimals.php" jsId="animalStore">
</div>
<select dojoType="dijit.form.FilteringSelect" store="animalStore" searchAttr="gr_name">
</select>
The search Attribute is processed correctly and the above response is sent back to the client, but the box remains empty.
I do not know how to map the custom JSON response to the label (value displayed as options and used for search : gr_name) and value (value returned on submit : gr_id) position of the dijit select box (FilteringSelect).
When I have been searching for examples, it always seems to work like magic, but I guess that is because they use a default structure for the json data. I can’t even confirm this, because the documentation is a bit scarse on those features.
Just extend the QueryReadStore and change the implementation to match your backend. Have a look at the various stores under dojox/data (http://trac.dojotoolkit.org/browser/tags/release-1.5.0/dojox/data) for examples of how to do this.
It’s hard to be more specific without knowing more about your backend. But if you look at the flickr store or any of the other stores which map to pre-existing non-dojo data sources you’ll get the idea.