0
我是鈦合金的新手。我正在用行創建一個自定義表格視圖。我連續添加了4個視圖。每個相應的視圖都有標籤--- >> Check In time,Check out time,Note and Time。檢入和檢出爲該任務提供時間。請注意添加註釋和時間以顯示檢入和註銷時間的差異。我想在數據庫中根據當前檢查時間更新注意特定任務。在特定的點擊行時,我無法捕獲當前「檢入時間標籤」上的文本。如果我收到檢查時間,我會根據當前檢查時間更新數據庫中的相應行。在tableview中點擊相應的行時獲取行數據
這是我的代碼。
function set(date,intime,outtime) var date1 = date;
var section = Ti.UI.createTableViewSection();
row1 = Ti.UI.createTableViewRow({layout:"horizontal"});
inview=Ti.UI.createView({
width:"25%",
});
inlabel=Ti.UI.createLabel({
text:intime,
font:{fontSize:13}
});
inview.add(inlabel);
outview=Ti.UI.createView({
width:"25%",
});
outlabel=Ti.UI.createLabel({
text:outtime,
font:{fontSize:13}
});
outview.add(outlabel);
inview.addEventListener('click',function(e){
// Ti.API.info(';',e.row1.rowID);
var picker=Ti.UI.createPicker();
picker.showTimePickerDialog({
callback: function(e){
if(e.cancel)
{
Ti.API.info('user canceled dialog');
}
else{
Ti.API.info('user selected date'+e.value);
var d=new Date(e.value);
var time=String.formatTime(d);
var newintime=d.getTime();
Ti.API.info(':'+time);
// var total=calculatetime(newintime,currouttime);
// timelabel.text=total;
inlabel.text=time;
//updateintime(date1,inlabel.text);
}
}
});
});
outview.addEventListener('click',function(e){
var picker=Ti.UI.createPicker();
picker.showTimePickerDialog({
callback: function(e){
if(e.cancel)
{
Ti.API.info('user canceled dialog');
}
else{
Ti.API.info('user selected date'+e.value);
var d=new Date(e.value);
var time=String.formatTime(d);
var newoutime=d.getTime();
Ti.API.info(''+newoutime);
// var total=calculatetime(currintime,newoutime);
// timelabel.text=total;
outlabel.text=time;
// updateoutime(date1,outlabel.text);
}
}
});
});
var timeview=Ti.UI.createView({
width:"25%",
});
var intime=parseInt(inlabel.text);
var outime=parseInt(outlabel.text);
var time=intime-outime;
var timelabel=Ti.UI.createLabel({
text:time,
font:{fontSize:13}
});
timeview.add(timelabel);
var noteview=Ti.UI.createImageView({
image:'TaskNote.png',
width:"15%",
});
noteview.addEventListener('click',function(e){
var tasknotewindow=Ti.UI.createWindow({
backgroundColor:'white',
layout:'vertical',
url:'TimeTracker/tasknote.js'
});
tasknotewindow.starttime=e.inlabel.text;
tasknotewindow.open();
});
var taskview=Ti.UI.createView({
width:"25%",
});
tasklabel=Ti.UI.createLabel({
text:"Click",
font:{fontSize:13},
});
//create window for task management
var taskmanagewindow = Ti.UI.createWindow({
backgroundColor: 'white', layout: 'vertical',
url:'TimeTracker/task.js'
});
//Task Dialog Box
taskoptionBox=Ti.UI.createOptionDialog({
title:'Task',
options:arrtaskname,
buttonNames:['Cancel'],
});
taskoptionBox.addEventListener('click',function(e){
tasklabel.text= arrtaskname[e.index];
});
tasklabel.addEventListener('click',function(e){
taskoptionBox.show();
});
taskview.add(tasklabel);
row1.add(inview);
row1.add(outview);
row1.add(timeview);
row1.add(noteview);
row1.add(taskview);
section.add(row1);
data.push(section);
table.setData(data);
}
我沒有geetting它...這裏的鏈接給出了數組的childern屬性的提示......但我的IDE沒有給我childern porperty – Aditya
IDE並不總是公開對象的所有功能。如果你正在尋找'intellisense'來啓動它,那麼它可能不適合這種功能。嘗試使用他的代碼進行試驗,看看它是否正常工作,而不依賴於IDE爲您編寫代碼。 – Martin
嗨,馬丁感謝您的幫助!我的查詢是不同的...我已創建自定義行有一個視圖和4個標籤...我想找到第一個標籤的文本(簽入)當我點擊表中的任何一行.. – Aditya