Hello I have sought the best way to populate a combobox with data from my database. I tried it this way, but I think there are better ways to do it in JavaScript.
Thank you all
var albumStore = new JsonRest({target:"/album", idAttribute:"id"});
var store = new Memory();
albumStore.query('').then(function(data) {
json = new Array();
for(i in data){
item = {
name: data[i].nome,
id: data[i].id
}
json[i] = item;
}
store .setData(json);
})
props = {
required : true,
missingMessage: 'campo obrigatório',
store: store
}
You can use Array slice method to clone arrays:
Please note, you can also use
JsonReststore directly withComboBox, if your REST server supports it. See how it works with fakeServer of sinon.js at this jsFiddle: http://jsfiddle.net/phusick/N8DqG/