Tableview in Titanium list

Source: Internet
Author: User

Effect:

 

Tableview to be created is displayed in the titanium list

VaR tableview = Ti. UI. createtableview ({style: Ti. UI. iPhone. tableviewcellselectionstyle. NONE // tableview style });

Each row in tableview is called tableviewrow.

Set haschild of tableviewrow to true to display the following results:

Click the haschild line to display the list (figure 2). You need to add a click event.

Tablerow. addeventlistener ('click', function (){
// Customize an event tablerow. fireevent ('haschildclicked', {operation: 'fieldchild '}) in titanium '});});

Capture this event

View. addeventlistener ('haschildclicked', function (e) {navgroup. Open (tableview); // use navigationgroup to open the list display screen tableview
});

 

Then the data is displayed in the list.

// Method for creating tableviewrow
Self. createtablerow = function (I) {var tablerow = Ti. UI. createtableviewrow (); tablerow. height = 50; // The Row Height Is tablerow. settitle ("tableviewrow" + I); // display name return tablerow;}; var rows = []; // array for storing tableview data (VAR I = 0; I <20; I ++) {rows. push (self. createtablerow (I);} tableview. setdata (rows); self. add (tableview );

 

The tableviewrow attribute hascheck controls whether the row is selected, similar to the checked attribute of the HTML checkbox control.

// Add a click event for each row to control its selected status
Tablerow. addeventlistener ('click', function () {If (tablerow. gethascheck () {tablerow. sethascheck (false);} else {tablerow. sethascheck (true );}});

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.