Question

this question update the oldest subject https://stackoverflow.com/questions/20609650/titanium-columnpicker-removeallchildren-methode/20612209?noredirect=1#20612209

i have a problem with the removeAllChildren methode from a ColumnPicker. http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.PickerColumn-method-removeAllChildren

Thinqs to @Krishna-Kumar , i'm near the result i want.

function pickercapteur(table)
{
    Ti.API.info("capteur ok");

    var test = column3.getRows();
    if(test != null)
    {
       for (var rowpicker in column3.getRows())
       {
             console.log(rowpicker);
             column3.removeRow(rowpicker);
             rowpicker =null;
       }
    }

    for(var i=0, ilen=table.length-1; i<ilen; i++){
        var row = Ti.UI.createPickerRow({title: table[i]});
        column3.addRow(row);
    }
    addpickercapteur();
}


    //Ti.API.info(column3.getRowCount());// ! if there is no row. it will CRASH appli instead of return 0, can't use it at the begin of my application!
//that why i use test!=null.

unfortnuatly , it doesn't delete the content, but i have a message in console : (as you can thinq, yes, i have 7 object in column3 when i want to remove it.)

[INFO][TiAPI   ( 2672)]  0
[WARN][PickerColumnProxy( 2672)] Unable to remove the row. Invalid type for row.
[INFO][TiAPI   ( 2672)]  1
[WARN][PickerColumnProxy( 2672)] Unable to remove the row. Invalid type for row.
[INFO][TiAPI   ( 2672)]  2
[WARN][PickerColumnProxy( 2672)] Unable to remove the row. Invalid type for row.
[INFO][TiAPI   ( 2672)]  3
[WARN][PickerColumnProxy( 2672)] Unable to remove the row. Invalid type for row.
[INFO][TiAPI   ( 2672)]  4
[WARN][PickerColumnProxy( 2672)] Unable to remove the row. Invalid type for row.
[INFO][TiAPI   ( 2672)]  5
[WARN][PickerColumnProxy( 2672)] Unable to remove the row. Invalid type for row.
[INFO][TiAPI   ( 2672)]  6
[WARN][PickerColumnProxy( 2672)] Unable to remove the row. Invalid type for row.

i try to removeselectedrow(); but only picker have this methode, not Columnpicker. i can't find any solution to remove it.

Was it helpful?

Solution

well.

Trash thing : i have the same result than before : null pointer exception. it was the same when i use removeAllRow().

there is no object betwin the moment you delete all and you put new one. (ty Captain obvious).so i have a null pointer exception.

here is my solution ,maybe not the best one ever. but effective. just put in a variable the number of rows you have, delete it AFTER you put new value.

function pickercapteur(table)
{
    Ti.API.info("capteur ok");
    var taille;
    test = column3.getRows();
    if (test != null)
    {
        taille = test.length -1;
    }

    //Ti.API.info(column3.getRowCount());// ! NE MARCHE PAS SI NULL ET PLANTE L'APPLI !

    for(var i=0, ilen=table.length-1; i<ilen; i++){
        var row = Ti.UI.createPickerRow({title: table[i]});
        column3.addRow(row);
    }

    if (taille != null)
    {
        for (var i = taille; i >= 0; i--){
          column3.remove(test[i]);
        };
    }
    addpickercapteur();
}

Hope that will help some people who encounter the same problem. Have a nice day.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top