I need to display the Picker values from Database. So How can I display the dynamic values in picker.
XML code
<Alloy>
<Collection src="UserLanguage"/>
<Window class="container" onClose="cleanup">
<Picker class="picker">
<PickerColumn dataCollection="UserLanguage" dataTransform="transformFunction">
<PickerRow title="{LanguageName}"/>
</PickerColumn>
</Picker>
<!--<Label id="label"></Label>-->
</Window>
</Alloy>
Model:
var moment = require('alloy/moment');
exports.definition = {
config : {
"columns": {
"id":"text",
"LanguageName":"text"
},
"adapter": {
"type": "sql",
"collection_name": "UserLanguage"
}
},
extendModel: function(Model) {
_.extend(Model.prototype, {
});
return Model;
},
extendCollection: function(Collection) {
_.extend(Collection.prototype, {
});
return Collection;
}
};
Controller
var moment = require('alloy/moment');
var userlang = Alloy.Collections.UserLanguage;
var task = Alloy.createModel('UserLanguage', {
id : '1',
LanguageName : 'English'
});
task.save();
userlang && userlang.fetch();
function transformFunction(model) {
var transform = model.toJSON();
transform.LanguageName = transform.LanguageName ;
return transform;
}
$.index.open();
function cleanup() {
$.destroy();
}
tss:
".container": {
backgroundColor:"black"
},
".picker": {
width: '90%',
top: '25dp'
}
Alloy.js
Alloy.Collections.UserLanguage = Alloy.createCollection('UserLanguage');
How can I pass the selected values in to Picker. The data is not binding in to the XML file, I'm getting the following error,
Uncaught TypeError: cannot read property '_transform' of undefined