1
저는 티타늄 API를 처음 사용합니다. DB에서 값을 검색하고 UI에 표시하는 방법을 알고 싶습니다. 모델을 만들고 행을 삽입했습니다.이Titanium Alloy의 데이터베이스에서 값을 검색하는 방법은 무엇입니까?
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;
}
};
보기 :이
<Alloy>
<Window id="changeLangWindow" title="Plan India">
<Picker id="langPicker">
<PickerRow title="Select a Language"/>
<PickerRow title="English"/>
<PickerRow title="French"/>
<PickerRow title="Spanish"/>
</Picker>
<Button class="button" onClick="saveLang">Proceed</Button>
<Label class="question">Selected Language is: -------</Label>
</Window>
</Alloy>
컨트롤러 :
function saveLang() {
var UserLang = Alloy.Collections.UserLanguage;
// Create a new model for the todo collection
var task = Alloy.createModel('UserLanguage', {
id : '1',
LanguageName : 'English'
});
// add new model to the global collection
UserLang.add(task);
// save the model to persistent storage
task.save();
// reload the tasks
UserLang.fetch();
}
내가 원하는 내 코드
가모델, 다음과 같습니다 "UserLanguage"모델에서 "LanguageName"값을 선택하고 XML 파일에있는보기에 표시하십시오.
설명이있는 모든 의견을 알려주십시오.
그래, 노력하고 있습니다. 하지만 WHERE 조건을 작성하려면 어떻게해야합니까? select LanguageName과 같이 id = 7; – Vinod
또한 UI에 선택한 값을 표시 할 수 있습니다. 그것은 js 파일에서 선택된 값을 xml로 전달하는 방법입니까? – Vinod
ID를 통해 다음과 같이 가져올 수 있습니다. "var model = Alloy.Collections.UserLanguage.get ("your id ");" – MRT