I am creating the table view with Expand/Collapse functionality. At first, Parent rows are creating. When I tap on parent row, then creating the new rows(by using tableView.insertRowAfter()).
var tableView = Ti.UI.createTableView({
style:Titanium.UI.iPhone.TableViewStyle.PLAIN,
top: 0,
height: "100%",
data: data
});
tableView.addEventListener("click", function(e) {
if(e.row.className == 'parent'){
var layoutId = e.row.layoutId;
var sublayoutArr = layout[layoutId].sub;
if(e.row.parentRightImageStatus == 'Expand'){
for(var i=sublayoutArr.length; i > 0; i = i - 1) {
tableView.deleteRow(e.index + i);
}
e.row.parentRightImageStatus = 'Collapse';
}
else{
// var data1 = [];
var currentIndex = e.index; var scrollIndex = currentIndex + sublayoutArr.length;
e.row.parentRightImageStatus = 'Expand';
for(var i=0; i < sublayoutArr.length; i++) {
Ti.API.info("currentIndex: "+currentIndex);
var rowObj = createRow(sublayoutArr[i].title,sublayoutArr[i].subTitle,false,sublayoutArr[i].status,layoutId,i);
tableView.insertRowAfter(currentIndex, rowObj);
currentIndex++;
Ti.API.info("i: "+i);
}
//tableView.setData([]);
/*setTimeout(function(){
tableView.setData(data1);
tableView.setContentInsets({top:0},{animated:true});
}, 1000);*/
//data1 = tableView.getData();
// tableView.setData([]);
// tableView.setData(data1);
tableView.scrollToIndex(scrollIndex ,{animated:true,position:Ti.UI.iPhone.TableViewScrollPosition.BOTTOM});
}
}
});
The issue is that the some of newly created rows data is not displaying in Android. For Ex., 3 rows I need to create if I am tapping on parent row. 2 rows data is displaying. third row data is not displaying. If I will scroll down and scroll up then 3rd row data is displaying. But it is working fine with iOS.
Please help me on this.