0

チタン初心者です。行を含むカスタム テーブル ビューを作成しています。4 つのビューを連続して追加しました。対応する各ビューには、ラベル --->> チェックイン時間、チェックアウト時間、メモ、時間があります。チェックインとチェックアウトは、タスクの時間を提供します。チェックイン時間とチェックアウト時間の差を表示するための注意事項と時間を追加します。現在のチェックイン時間に従って、データベース内の特定のタスクのメモを更新したいと考えています。特定の行をクリックしたときに、現在のチェックイン時間ラベルのテキストをキャプチャする方法がありません。チェックイン時間を取得すると、現在のチェックイン時間に従ってデータベース内の対応する行を更新します。

これが私のコードです。

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);

}

4

1 に答える 1

1

この質問/回答を確認してください。おそらく、これを使用して目的を達成できるでしょう。私はあなたが両方とも同じことをしようとしていると思います。

tableviewrow で子クリックを検索または追跡する方法 (Titanium Studio)

これは私がいつもこれを達成してきた方法です:

row1 = Ti.UI.createTableViewRow({
  layout:"horizontal",
  myval: intime // <=== Add your value here that you want to query for.
});
...
inlabel=Ti.UI.createLabel({
  text:intime,
  font:{fontSize:13}
});
inview.add(inlabel);
...

tableview.addEventListener('click', function(e){
  alert(e.rowData.myval);
});
...

// This section seems jumbled.  Should be something along the lines of the following...
// You have:
// section.add(row1);
// data.push(section);
// table.setData(data);
// Change to:
data.push(row1);
table.setData(data);
section.add(table);

もともと、あなたのコメントに基づいて、行内のラベルを操作したいと思っていましたが、今は違うようです。

于 2012-12-26T14:51:23.507 に答える