Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11629] TiAPI: TableView getRowByName

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionWon't Fix
Resolution Date2014-02-21T01:04:00.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTiAPI
Labelsn/a
ReporterMartin Guillon
AssigneeVishal Duggal
Created2012-10-10T09:16:47.000+0000
Updated2017-03-22T17:29:55.000+0000

Description

As we have a getRowIndexByName (which by the way is not documented), I thought it would be a great idea to simply have a getRowByName that directly returns the rows so that you can interact with it. In the test case i use it in a click event, which is dumb as you already have e.row, but it s very useful in more complex cases.
var win = Titanium.UI.createWindow();
win.backgroundColor = '#ccc';

var tableview = Ti.UI.createTableView();
win.add(tableview);

var rowData = [];
for (var i = 0; i < 10; i++) {
	var row = Ti.UI.createTableViewRow({
		title : 'row ' + i,
		name : 'row ' + i
	});
	rowData.push(row);
};
tableview.data = rowData;

tableview.addEventListener('click', function(e) {
	if (e.row) {
		Ti.API.info(JSON.stringify(e.row))
		var row = tableview.getRowByName(e.row.name);
		alert('click on row with name "' + e.row.name + '" and the getRowByName return a row with name "' + row.name + '"')
	}
})

win.open();

Comments

  1. Martin Guillon 2012-10-10

    pull request https://github.com/appcelerator/titanium_mobile/pull/3148
  2. Ingo Muschenetz 2014-02-21

    We are not currently adding new features to TableView. Thank you for the request and the code submission. If people wish to add this functionality, they are welcome to merge the code from the PR.
  3. Lee Morris 2017-03-22

    Closing ticket as the issue will not fix and with reference to the above comments.

JSON Source