Is is possible for multiple filtering selects (or combo boxes) to use different sets of data inside a single JSON data store?
I have a form with multiple FilteringSelects, whose items I want to retrieve from a file on the server, but I don't want to have to have a separate file for each FilteringSelect.
I was hoping that I could use the ItemFileReadStore to load a single JSON Data file that contains the multiple sets of items that I can use to populate multiple FilteringSelects.
Here is what I thought might work
The JSON Data File (data.json)
identifier: 'data2', items: [{data2: 'value3'}, {data2: 'value4'}]}
The Dojo Code
<input dojoType="dijit.form.FilteringSelect" store="dataStore" searchAttr="data1" />
<input dojoType="dijit.form.FilteringSelect" store="dataStore" searchAttr="data2" />
The anticipated output would be have 'value1' and 'value2' in the first FilteringSelect, and 'value3' and 'value4' in the second FilteringSelect.
Is this feasible?
When I try this the output only populates the second FilteringSelect with 'value3' and 'value4', the first Select is empty.
TIA!

Solution: Define FilteringSelect Query Property
The solution I found to this problem is the use the 'query' property when defining the FilteringSelect.
The JSON Data file (data.json) should follow this structure
items: [
{type: 'data1', name: 'Value 1', }, {type: 'data1', name: 'Value 2', },
{type: 'data2', name: 'Value 3', }, {type: 'data2', name: 'Value 4', },
]}
The required HTML code looks like this
<input dojoType="dijit.form.FilteringSelect" store="dataStore" query="{type: 'data1}" />
<input dojoType="dijit.form.FilteringSelect" store="dataStore" query="{type: 'data2}" />
Now I have a single JSON data file providing the options for multiple FilteringSelects (this should work for ComboBoxes too)
I hope this can help someone else out too..
i don't know if your need
i don't know if your need fits this idea but there is also a searchAttr for the FilteringSelect. so your store might be like this:
items: [
{trackId: '1', album: 'album1', artist: 'artist1', title: 'artist1 - album1 - title1'},
{trackId: '2', album: 'album1', artist: 'artist1', title: 'artist1 - album1 - title2'},
{trackId: '3', album: 'album1', artist: 'artist1', title: 'artist1 - album1 - title3'},
{trackId: '4', album: 'album2', artist: 'artist2', title: 'artist2 - album2 - title1'},
{trackId: '5', album: 'album3', artist: 'artist3', title: 'artist3 - album3 - title3'}
]}
and then you might have some FilteringSelects like this
store="musicStore" pageSize="5" searchAttr="artist" query="{artist:'*'}"/>
Album: <input id="album" dojoType="dijit.form.FilteringSelect"
store="musicStore" pageSize="5" searchAttr="album" query="{album:'*'}"/>
both of these above would be working on the same rows of data but displaying different attributes of the same data. from your example, it looks like yours would end up working on separate rows of data even though all the rows are in the same store. just thought i would chime in with an alternative scenario that is similar but not quite the same - both examples are ways to have 2 different FilterSelects working from the same store.
and while i have your attention... if anyone knows how to query the store for "unique" values i would like to know. in the example above the album FilteringSelect will show:
album1
album1
album1
album2
album3
i would like it to show:
album1
album2
album3
Possible way to do this
Thanks for the interesting reply. Yes, I was trying to achieve serparate rows of data in the same store. That way I don't need to maintain several JSON data files.
In regards to your scenario, I came up with one alternative, see what you think.
JSON Store
I set the identifier to the be the item name, which is why I have called albums 'album1-1', literally artist1-album1. For your real data it would be just the album name (assuming you don't have two artists with the same album name of course).
items: [
{type: 'artist', name: 'artist1'},
{type: 'artist', name: 'artist2'},
{type: 'artist', name: 'artist3'},
{type: 'album', artist: 'artist1', name: 'album1-1'},
{type: 'album', artist: 'artist1', name: 'album1-2'},
{type: 'album', artist: 'artist2', name: 'album2-1'},
{type: 'album', artist: 'artist3', name: 'album3-1'},
{type: 'title', album: 'album1-1', name: 'title1-1-1'},
{type: 'title', album: 'album1-1', name: 'title1-1-2'},
{type: 'title', album: 'album1-2', name: 'title1-2-1'},
{type: 'title', album: 'album2-1', name: 'title2-1-1'},
{type: 'title', album: 'album2-1', name: 'title2-1-2'},
{type: 'title', album: 'album3-1', name: 'title3-1-1'},
{type: 'title', album: 'album3-1', name: 'title3-1-2'}
]}
The HTML code I used allowed me to have FilteringSelects that show the list of artists, albums and title/tracks as well as query the albums for a particular artist, etc
url="dataStore.json" />
<span>All Artists</span>
<div dojoType="dijit.form.FilteringSelect" store="dataStore"
query="{type: 'artist', name: '*'}" />
<span>All Albums</span>
<div dojoType="dijit.form.FilteringSelect" store="dataStore"
query="{type: 'album', name: '*'}" />
<span>All Titles</span>
<div dojoType="dijit.form.FilteringSelect" store="dataStore"
query="{type: 'title', name: '*'}" />
<span>Albums for Artist 1</span>
<div dojoType="dijit.form.FilteringSelect" store="dataStore"
query="{type: 'album', artist: 'artist1'}" />
<span>Titles in Album 2</span>
<div dojoType="dijit.form.FilteringSelect" store="dataStore"
query="{type: 'title', album: 'album2-1'}" />
The first set of FilteringSelects display all unique Artists, Albums and Titles (using the 'name' field).
The second set of FilteringSelects display albums for artist1 and titles for album2-1.
Another method I thought might work would be to arrange a store similar to the Tree example in the Dojo documentation and Dijit Tests, using 'children' items.
The store may look like this (though I haven't got it working)
items: [
{type: 'artist', name: 'artist1', children:[{_reference: 'album1-1'}, {_reference: 'album1-2'}]},
{type: 'album', name: 'album1-1', children:[{_reference: 'title1-1-1'}, {_reference: 'title1-1-2'}]},
{type: 'title', name: 'title1-1-1'},
{type: 'title', name: 'title1-1-2'},
{type: 'album', name: 'album1-1', children:[{_reference: 'title1-1-1'}, },
// add more artists, albums, titles, etc
]}
I don't know if the querying for this JSON data could be applied to FilteringSelects though.