[TIMOB-5509] MobileWeb: Method tableView.setData([]) works only once.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-09-08T04:41:25.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.7.2 |
Components | MobileWeb |
Labels | qe-port |
Reporter | Misha Vasko |
Assignee | Neeraj Gupta |
Created | 2011-09-01T03:09:32.000+0000 |
Updated | 2012-08-28T10:50:47.000+0000 |
Description
After one call of tableView.setData([]) the tableView becomes unavailable for adding new rows by methods tableView.appendRow() or tableView.setData(data).
How to reproduce: Run example > click "Fill table" > click "Clear Table" > click "Fill table".
Expected behavior: tableview should be filled by rows after second click against the "Fill table" button.
var win = Ti.UI.currentWindow;
win.backgroundColor = '#EEE';
var tableView = Ti.UI.createTableView({
width: 300,
height: 200,
top: 155,
left: 10,
backgroundColor: '#AAA'
});
var addRow = Ti.UI.createButton({
title: 'Clear table',
width: 140,
top:5,
left: 10,
height: 50,
fontSize: 16
});
var delRow = Ti.UI.createButton({
title: 'Delete row',
width: 140,
top:5,
height: 50,
left: 160,
fontSize: 16
});
var fillTable = Ti.UI.createButton({
title: 'Fill table',
width: 140,
height: 50,
top:60,
left: 10,
fontSize: 16
});
var label1 = Ti.UI.createLabel({
top: 115,
left: 53,
width: 100,
height: 30,
text: 'Row index:',
});
var tf1= Ti.UI.createTextField({
width: 50,
height: 30,
top:115,
backgroundColor:'white',
left: 178,
value: '1'
});
var closeButton = Ti.UI.createButton({
title:'Close Window',
height:50,
width:140,
top:60,
left:160,
fontSize: 16
});
closeButton.addEventListener('click', function(){
Titanium.UI.currentWindow.close();
});
win.add(closeButton);
win.add(fillTable);
win.add(tableView);
win.add(addRow);
win.add(delRow);
win.add(tf1);
win.add(label1);
var i = 1;
var newRow = function (){
row = Ti.UI.createTableViewRow({
title: 'This is row #' + i
});
i++;
};
addRow.addEventListener('click', function(){
tableView.setData([]);
// newRow();
// tableView.appendRow(row);
});
delRow.addEventListener('click', function(){
tableView.deleteRow(parseInt(tf1.value)-1);
});
fillTable.addEventListener('click',function(){
var data = [{title:'This is row #1'},
{title:'This is row #2'},
{title:'This is row #3'},
{title:'This is row #4'},
{title:'This is row #5'}];
i=6;
tableView.setData(data);
});
Method tableview.setData() should reset the previous data in the tableview. Now it adds the new data to the end of tableview.
Verified fix on: Titanium studio : 2.1.1.201207271312 SDK version : 2.2.0.v20120827143312 Chrome 21.0.xx Firefox 15 Safari 6.0 Android 4.0.4 default browser,chrome 18.0.xx ,firefox 15.0 Iphone 5.0.1 mobile safari