I want to get the selected row value from tableview and copy to textfiled for appcelerator

hello everyone I want to get the selected string value in a text box so that I can copy the value to textfiled as possible. 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; } }); 
+6
source share
5 answers

1) Create a row and append rowid or any other data that you want to associate with the row.

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

2) Add to the table adding clicks of event events:

 tableView.addEventListener('click', selectRow); 

3) In the selectRow function, get the data.

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

You can simply add "rowid" to each row. And create an eventListener on your table as you did, and get the value using "e.row.rowid".

0
source

you should insert a constructor like this

 var row = Titanium.UI.createTableViewRow({ hasChild:true, title:rows.fieldByName('title'), rowId:rows.fieldByName('id'), path:'nextView.js' }); 
0
source
 tab.addEventListener('click',function(e) { var ind = e.index; if(e.selectRow) { Titanium.API.inof(' Selected clicked'); my_combo.value = e.rowData.title; } }); 
0
source

Just replace e.selectRow with e.row in your code.

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

Source: https://habr.com/ru/post/887823/


All Articles