inputEx - DSSelectField Usage

Using a DataSource

How to populate the selectField using a YUI datasource (from local data, XHR, JSONP, function, ...):

1var myDataSource = new YAHOO.util.XHRDataSource("books.json");  
2myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; 
3myDataSource.responseSchema = { fields: ["id","quantity","amount","title""category"], resultsList: "Results" }; 
4 
5new inputEx.DSSelectField({name: 'country', datasource: myDataSource, valueKey: "id", labelKey: "title", parentEl: 'container1'}); 
view plain | print | ?

Updated event

How to listen to the updated event :

Log :
1var myDataSource = new YAHOO.util.XHRDataSource("books.json");  
2myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; 
3myDataSource.responseSchema = { fields: ["id","quantity","amount","title""category"], resultsList: "Results" }; 
4 
5var el = YAHOO.util.Dom.get('container2'); 
6var field2 = new inputEx.DSSelectField({name: 'country', datasource: myDataSource, valueKey: "id", labelKey: "title", parentEl: el}); 
7 
8var logDiv = inputEx.cn('div'nullnull"Log :"); 
9el.appendChild(logDiv); 
10field2.updatedEvt.subscribe(function(e,params) { 
11    var value = params[0]; 
12    logDiv.innerHTML += "Updated at "+(new Date())+" with value "+value; 
13    logDiv.appendChild(inputEx.cn('br')); 
14}); 
view plain | print | ?

Set Value

How to set the value :

1var myDataSource = new YAHOO.util.XHRDataSource("books.json");  
2myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; 
3myDataSource.responseSchema = { fields: ["id","quantity","amount","title""category"], resultsList: "Results" }; 
4 
5var el = YAHOO.util.Dom.get('container3'); 
6var field3 = new inputEx.DSSelectField({name: 'country', datasource: myDataSource, valueKey: "id", labelKey: "title", parentEl: el}); 
7 
8var setValueButton = inputEx.cn('button'nullnull"setValue to po-1482"); 
9el.appendChild(setValueButton); 
10YAHOO.util.Event.addListener(setValueButton, 'click'function(e,params) { 
11    field3.setValue("po-1482"); 
12}); 
view plain | print | ?