i want to get selected row value from tableview and copy into textfiled for appcelerator

17,809

1) Create the row and attach the rowid to it, or whatever other data you want to associate to a row.

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

2) Add click event listener to the table:

tableView.addEventListener('click', selectRow);

3) In selectRow function, get the data.

function selectRow(e) {
 var rowId = e.rowData.rowId;
 var myText = e.rowData.myText;
 myTextField.value = myText;
}
Share:
17,809
Anjan
Author by

Anjan

Updated on June 18, 2022

Comments

  • Anjan
    Anjan almost 2 years

    hi all i want to get selected row value into textfield so how can i copy the value into the textfiled. so how can i do this...my_combo is textfiled Code -:

    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;
        } 
    
    });
    
  • Justin
    Justin about 13 years
    Close, however I think it should be e.rowData.rowid. If e.row works as well then let me know, I've never tried that.
  • Anjan
    Anjan about 13 years
    Thanks for your help... i have another problem that how can i use soap based webservice in my apps. kitchensink ex. is not worked properly so can u give me any tutorial or code for it.
  • Anjan
    Anjan about 13 years
    Thanks for your help... i have another problem that how can i use soap based webservice in my apps. kitchensink ex. is not worked properly so can u give me any tutorial or code for it.
  • Aaron Newton
    Aaron Newton over 9 years
    Under Titanium v3.0 I had to add my additional properties in the method constructor as shown here: developer.appcelerator.com/question/135791/…. E.g. var row = Titanium.UI.createTableViewRow({ target: tableOptions[i].target }); - I could then use e.rowData.target in my event handler function.