views:

1662

answers:

2

I'm trying to use a dojo combobox with an Ajax data source. What I have is

<div dojoType="dojo.data.ItemFileReadStore" 
     jsId="tags" 
     url="<%=ResolveClientUrl("~/Tag/TagMatches")%>" >
</div>
<select dojoType="dijit.form.ComboBox" 
        store="tags" 
        value="" 
        name="tagName">
</select>

Which does work except that I can't restrict the search set on the server side because I don't know how to change the url from which the data is pulled in order to specify a parameter. Any hints?

+1  A: 

If I understand you correctly, you want the client to load different set of data from the server based on some general condition defined elsewhere.

Basically there is no need to have a <div> pre-defined. You can also create the ItemFileReadStore directly in JavaScript:

earlier...:

var tagMatchUrlBase = '<%=ResolveClientUrl("~/Tag/TagMatches")%>';

later...:

var tagMatchUrl = tagMatchUrlBase + "?f=" + escape(somefilterString);
var store = new dojo.data.ItemFileReadStore({url: tagMatchUrl});
tagName.store = store;
// maybe use store.fetch() to pre-select item #1
Tomalak
As it turns out this was the least of my problems but your solution worked great, thanks.
stimms
A: 

Typically this isn't done with ItemFileReadStore, which is designed to download all the data up front rather than filtering on the server.

Rather, you should use QueryReadStore, JsonReadStore, etc.