Title: How to change displayed value in dojox DropDownSelect
Tags: javascript;dojo
Question: I have DropDownSelect declared with tags:
<select id="someId" dojoType="dojox.form.DropDownSelect" &gt;
<option&gt;Loading...</option&gt;
</select&gt;
Then when xhr load function is called I would like to remove the option above and create the new one "Choose Option", for example.
load: function(response) {
//remove option, but it stays as displayedValue, displayed
dojo.byId("someId").removeChild(dojo.byId("someId").lastChild);
//I would like to show the option below
dijit.byId("someId").addOption({label: "Choose Option", value:"Select"});
//dijit.byId("someId").setAttribute('displayedValue','Select'); // not working
dijit.byId("someId").addOption(response); // add ajax options.
return response;
},
Please, tell me how to show different option in DropDownSelect??? The version 1.3 is used.

Here is the accepted answer: //1. html: define drop down
<select id="ddselect" name="select" dojoType="dojox.form.DropDownSelect"&gt;
<option value="none"&gt;
Loading...
</option&gt;
</select&gt;
// 2. onLoad handler:
load: function(response) {
// get widget by id
var dd = dijit.byId("ddselect");
// remove loading option
dd.removeOption(0);
// add new option
dd.addOption({ label: 'newValue1', value: 'nv1'});
// or add array of options
dd.addOption([{ label: 'newValue2', value: 'nv2' }, { label: 'newValue3', value: 'nv3'}]);


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2011:00:03/31/11', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<javascript><dojo>', 'Title': 'How to change displayed value in dojox DropDownSelect', 'ViewCount': 551, 'id': 5504679, 'user_AboutMe': '', 'user_AccountId': 287634.0, 'user_DisplayName': 'Sqeezer', 'user_Reputation': 1217.0, 'user_Views': 70.0, 'user_id': 587574.0}}