【问题标题】:i want to get selected row value from tableview and copy into textfiled for appcelerator我想从 tableview 中获取选定的行值并复制到 textfiled 以供 appcelerator
【发布时间】:2011-08-23 06:30:42
【问题描述】:

大家好 我想将选定的行值放入文本字​​段中,那么如何将值复制到文本文件中。那么我该怎么做...my_combo 是文本文件 代码-:

var Tab_data = [

     { title:'Row 1', hasChild:true },
     { title:'Row 2', hasChild:true },
     { title:'Row 3', hasChild:true },
     { title:'Row 4', hasChild:true }
];


var tab = Titanium.UI.createTableView({
    top:43,
    data:Tab_data
});

tab.selectionIndicator=true;

tab.addEventListener('click',function(e) {

    var ind = e.index;

    if(e.selectRow)
    {
        Titanium.API.inof(' Selected clicked');
        my_combo.value = e.selectRow.title;
    } 

});

【问题讨论】:

    标签: titanium appcelerator


    【解决方案1】:

    只需在您的代码中将 e.selectRow 替换为 e.row。

    tab.addEventListener('click',function(e) {
    
        var ind = e.index;
    
        if(e.row)
        {
            Titanium.API.inof(' Selected clicked');
            my_combo.value = e.row.title;
        } 
    
    });
    

    【讨论】:

      【解决方案2】:
      tab.addEventListener('click',function(e) {
      
          var ind = e.index;
      
          if(e.selectRow)
          {
              Titanium.API.inof(' Selected clicked');
              my_combo.value = e.rowData.title;
          } 
      });
      

      【讨论】:

        【解决方案3】:

        你应该像这样放入构造函数

        var row = Titanium.UI.createTableViewRow({
            hasChild:true,
            title:rows.fieldByName('title'),
            rowId:rows.fieldByName('id'),
            path:'nextView.js'
        
            }); 
        

        【讨论】:

          【解决方案4】:

          1) 创建行并将 rowid 附加到该行,或者您想要关联到行的任何其他数据。

          var row = Ti.UI.createTableViewRow();
          row.rowId = 1;
          row.myText = "hello world";
          

          2) 给表格添加点击事件监听器:

          tableView.addEventListener('click', selectRow);
          

          3) 在 selectRow 函数中,获取数据。

          function selectRow(e) {
           var rowId = e.rowData.rowId;
           var myText = e.rowData.myText;
           myTextField.value = myText;
          }
          

          【讨论】:

          • 感谢您的帮助...我还有一个问题是如何在我的应用程序中使用基于肥皂的网络服务。厨房水槽前。不能正常工作,所以你能给我任何教程或代码吗?
          • 在 Titanium v​​3.0 下,我必须在方法构造函数中添加我的附加属性,如下所示:developer.appcelerator.com/question/135791/…。例如。 var row = Titanium.UI.createTableViewRow({ target: tableOptions[i].target }); - 然后我可以在我的事件处理函数中使用 e.rowData.target .
          【解决方案5】:

          您只需将“rowid”添加到每一行即可。并像您一样在您的表上创建一个 eventListener 并使用“e.row.rowid”检索值。

          【讨论】:

          • 关闭,但我认为应该是 e.rowData.rowid。如果 e.row 也能正常工作,请告诉我,我从未尝试过。
          • 感谢您的帮助...我还有一个问题是如何在我的应用程序中使用基于肥皂的网络服务。厨房水槽前。不能正常工作,所以你能给我任何教程或代码吗?
          猜你喜欢
          • 2017-07-30
          • 2016-06-28
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-05-02
          • 2016-01-27
          • 1970-01-01
          • 2021-12-15
          相关资源
          最近更新 更多