Carlos Gavidia-Calderon
Carlos Gavidia-Calderon

Reputation: 7253

Dojo: FilteringSelect and ItemFileWriteStore

I'm using Dojo 1.5 for building a Web Application. Currently, I'm trying to make a Form to fill some data in the Database, and this form needs a ComboBox with some pre-loaded data for the user to select. What I'm trying to do is declare that combo with ItemFileWriteStore as data source and FilteringSelect as the Widget. The ItemFileWriteStore goes like this:

<div dojoType="dojo.data.ItemFileWriteStore" jsId="itemsStore" url="rest/items">
</div>

The rest/items URI return this:

{"items":[{"id":1003,"description":"And Item","name":"Items"}]}

And my Combo widget goes like this:

<input dojoType="dijit.form.FilteringSelect" name="item_edited" 
store="itemsStore" searchAttr="name" id="item_edited" required="true" />

When I load the form I can see the FilteringSelect with the data that comes from the REST Service. But when I select the only item in the Combo and make a POST request to persist the data, I'm seeing this in Firebug:

Parameters (application/x-www-form-urlencoded)

form_item          123
another_form_item  foo
item_edited        1

So I expect thed attribute id from the JSON type (that for the only item returned is 1003) to be sent to the Server, but I'm getting son ordinal position instead. How do I tell FilteringSelect to use the id attribute of the JSON returned as value?

Upvotes: 0

Views: 533

Answers (1)

Harnish Patel
Harnish Patel

Reputation: 26

You can specify the identifier attribute in the JSON returned from the URI:

{"identifier" : "id", "label" : "name", "items":[{"id":1003,"description":"And Item","name":"Items"}]}

Upvotes: 1

Related Questions