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 );}});