Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Delete row from tableView and from array with editable propriety - Titanium with Alloy.

$
0
0

Hello,

I have an array "data" that contains rows. I have a TableView that displays the rows contained into the data array.

I would like to allow the user to delete rows. For that, I've use de "editable" propriety of rows. I set the editable property to "true".

When I swipe, I can delete the row.

Untile there everything is fine.

The problem comes next.

When I add a row and I reload the tableView, the row previously deleted appear again.

I think that the problem is that when I delete the row, it deletes it from the view but not from the data array! So when I add arrow, reload, it displays the rows contained in the data array which are the old ones (that haven't been correctly deleted) and the new ones, I juste added.

Can you help me delete the rows definitely ?

Thanks!

This is how data is defined.

var data = [row1 = Alloy.createController('row', {
    primaryLabel: 'test',
    subTitle: 'test2',
    rownum: 0,
    backgroundImage:"/images/yellow.png",
    hour:"10:50",
    editable:true
    }).getView()];
This is how I add to the data.
function addToData(){
    var row = Alloy.createController('row', {
    primaryLabel: $.cityInput.value,
    subTitle: $.hoursInput.value,
    rownum: data.length,
    //myImage: (i%2==0) ? 'a' : 'b'
    backgroundImage:selectRowImage(data.length),
    editable:false
    }).getView();
    data.push(row);
    tintin=Alloy.createController('index').getView('theTable');
    tintin.setData(data);
    $.addcity.close();
}

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>