obaid
obaid

Reputation: 902

Table view Section Header Title in titanium

I have created a custom Header view for the tableview in my Titanium project,

 var headerView = Ti.UI.createView({ height: 40,backgroundColor:'#00928F' });
    var headerLabel = Ti.UI.createLabel({ text: array_interview_dates[i],color:'white' });
    headerView.add(headerLabel);    
    headerViewArray.push(headerView);

And now when I want to get the section header Title when I select the row

table.addEventListener('click', function action_table(e){
 var header_title=e.section.headerTitle;
}

I get empty value, I want to get the section_HeaderTitle

Upvotes: 0

Views: 1152

Answers (1)

maxdangelo
maxdangelo

Reputation: 3133

In your code there is no definition of a section.

You should define the property headerTitle inside the section definition to have it available, like in this example (Adapted from Titanium documentation):

Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow();

var sectionFruit = Ti.UI.createTableViewSection({ headerTitle: 'Fruit' });
sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Apples' }));
sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Bananas' }));

var sectionVeg = Ti.UI.createTableViewSection({ headerTitle: 'Vegetables' });
sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Carrots' }));
sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Potatoes' }));

var table = Ti.UI.createTableView({
    data: [sectionFruit, sectionVeg]
});

table.addEventListener('click', function(e){
    Ti.API.info(e.rowData.title);
    Ti.API.info(e.section.headerTitle);
});

win.add(table);
win.open();

Upvotes: 1

Related Questions