tableView index Event problem
Hi,
I'm working on a table view, and want to add an Index (the little bar in rightside with vertical swipe)
Took KitchenSink sample, it dosen't work (in KitchenSink, and my project) : the index appear, but make no swipe
I think there is an Event Listener somewhere, but can't find it….
Thanks for your Help !!!
Here is my code :
var tableSocOptions = {
data : dataSoc,
separatorStyle:Ti.UI.iPhone.TableViewSeparatorStyle.NONE,
rowBackgroundColor : 'white'
};
var tableSoc = Titanium.UI.createTableView(tableSocOptions);
var indexSoc = [
{title:'A',index:0},
{title:'B',index:16},
{title:'C',index:25}
]
tableSoc.index = indexSoc;
this is the strict implementation of KitchenSink, and i don't see the event listener for make the vertical Swipe.
Actually, clicking on the index in my table just rewind my list in the top….
2 Answers
-
I just realize that i have no Header in my rows, and index is linked with Header in rows.
But this is a little confusing, because in index we put index Objects with Title AND index row position….
SO i think you may want to put in documentation that you need Header for make index…
;)
-
ok I got this by setting an empty 'header' property for each item in the data object passed into the TableView.data property. Like:
while (words.isValidRow()) {
retval.push({title:words.fieldByName('eng_word'), header:''});
words.next();
}
words.close();
return retval;
Where 'words' is a SQLite recordset.
The TableView.index is set with a function shown below:
function makeTableIndex() {
var retval = null;
retval = [ {title:' ',index:1}, {title:' ',index:2},
{title:'A',index:75}, {title:'C',index:194}, {title:'E',index:365},
{title:'G',index:467}, {title:'I',index:532}, {title:'K',index:562},
{title:'M',index:626}, {title:'P',index:751}, {title:'R',index:826},
{title:'S',index:869}, {title:'U',index:1056}, {title:'W',index:1091},
{title:'Z',index:1136} ];} return retval;
}
This displays the table properly (without any separators between any of the rows). And the index on the right of the TableView functions properly as well.