我想删除一个带有按钮的行。我有以下代码:
depAgregarButton.addEventListener('click', function(e){
dataBase('insert', depNamesField.value );
var databaseObj = new dataBase('query', null),
data = [];
for(var i in databaseObj ){
var row = Ti.UI.createTableViewRow({
title: databaseObj[i],
backgroundColor:'#FFF',
height: '35dp'
});
var label = Ti.UI.createLabel({
color: '#727072',
objName: 'label',
text: databaseObj[i],
touchEnabled: false,
left: '12dp',
width: '250dp',
font: {
fontSize:'12dp',
fontFamily:'HelvLight Regular'
}
});
var buttonDelete = Ti.UI.createButton({
backgroundImage: '/images/but_x.png',
width:'30dp',
height:'30dp',
right: '8dp',
clickName:'button'
});
data.push(row);
row.add(label);
row.add(buttonDelete);
};
table.appendRow(row);
});
我正在向表中添加行,但我不知道如何使用deleteButton删除每一行
答案 0 :(得分:0)
尝试这个
table.addEventListener('click',function(e){
if(e.source.clickName){
if(e.source.clickName == 'button'){
table.deleteRow(e.row);
}
}
});