i am working on Expandable Table View Row My problem is
i have given image for parent row Plus and minus image on click of parent
row plus image should hide and minus image should and if i again click
the minus image should hide and plus image should show.
My output : on click of first row its working for only last row image hiding
and showing ?
you can see my screen shot i clicked first row and change the
image of third row
http://i.stack.imgur.com/w5MVq.png
my second query is that if click parent 2 row the previous child
should collapse
code
~~~
var rowData = [];
var downImage='image/minus.png';
for(var i=0; i<=2; i++){
var row = Titanium.UI.createTableViewRow(
{
height: 'auto',
className: 'board_row',
isparent: true,
opened: false,color:'black',
sub: [
{
title: "child :1",
color:'blue'
},
{
title: "child :2",
color:'blue'
},
{
title: "child :3",
color:'blue'
},
{
title: "child :4",
color:'blue'
},
{
title: "child :5",
color:'blue'
},
{
title: "child :6",
color:'blue',
}
]
});
var serviceLabel = Titanium.UI.createLabel(
{
text:"Parent :" +i ,
font: {fontSize: 18,fontWeight: 'bold'},
width: 'auto',
height: 'auto',
textAlign: 'left',
color: 'black',
left: 4
});
var plusimage = Ti.UI.createImageView({
image:'image/plus.png',
width:'20',
height:'20',
right:10,
top:10
});
var minus = Ti.UI.createImageView({
image:'image/minus.png',
width:'20',
height:'20',
right:10,
visible:false,
top:10
});
row.add(serviceLabel);
row.add(minus);
row.add(plusimage);
rowData.push(row);
}
tableView.setData(rowData);
tableView.addEventListener('click', function(e) { //Is this a parent cell? if(e.row.isparent) {
// alert("1");
//Is it opened?
var i, rows;
if (e.row.isparent) {
//alert("2");
//Is it opened?
if (e.row.opened) {
// alert("3");
plusimage.show();
minus.hide();
for (i = e.row.sub.length; i > 0; i = i - 1) {
tableView.deleteRow(e.index + i);
// alert("4");
}
e.row.opened = false;
//alert("5");
} else {
rows = e.row.sub.reverse();
// plusimage.hide();
//minus.show();
for (i = 0; i < rows.length; i++) {
tableView.insertRowAfter(e.index, rows[i]);
}
e.row.opened = true;
plusimage.hide();
minus.show();
// alert("6");
}
}
});
~~~
↧