Month: February 2015

Titanium tableView rowData id missing in android but working in iOS

I found a strange problem while coding in Titanium

I first tested my code on iOS only and not on android. Now in one of the table I redesigned the rows with height etc.

Now I was accessing the onClick event, but in e.rowData.id the value was missing. I don’t know why.

So I used the following code to get the access of ID and so that it works on both android as well as iOS

	console.log('**********MY EXPERIMENT ***********');
	for (var i = 0; i < dataArray.length; ++i) {
		console.log('IN FOR LOOP' + i);
		var row = Titanium.UI.createTableViewRow();
		//row.layout = 'vertical';
		row.id = dataArray[i].id;
		row.backgroundColor = '#000000';

		var e_code = Titanium.UI.createLabel({
			text : dataArray[i].display_panel_code,
			font : {
				fontSize : '24dp',
				fontWeight : 'bold',
				fontFamily : 'Digital-7'
			},
			color : "#00FF04",
			//width : '30%',
			textAlign : 'left',
			left : '20dp'

		});
		row.add(e_code);

		led_code = dataArray[i].led_code;
		console.log('**********LED CODE : ' + led_code);
		if (led_code != null || led_code != '') {
			ledImages = createLedImage(led_code);
			ledImages.left = '120dp';
			row.add(ledImages);
		}

		var e_summary = Titanium.UI.createLabel({
			text : dataArray[i].summary,
			font : {
				fontSize : '14dp',
			},
			color : "#FFFFFF",
			//width : '70%',
			textAlign : 'left',
			left : '20dp',
			height : 'auto',
			top : '40dp'
		});

		row.add(e_summary);
		
		
		row['errorcode_id']=dataArray[i].id;///added to support the android applications and ios both

		//row.className = 'e_code_row';

		my_array.push(row);
	}///end of for

and to accesss it I used

console.log(e.row['errorcode_id']);
Advertisements