tags:

views:

11

answers:

1

Is it possible to Remove an item from the ListView by not removing it's content[] ?

I tried changing the visibility of an item, but it does not give that removed effect it in. Instead it just gives you an empty space in between the data.

i.e.

    var customNodes : Foo[] = [Foo{bar:"help"}, 
                       Foo{bar:"me"}, Foo{bar:"please"}];   
    ListView { 
      ...
      contents : bind customNodes;
    }

Now, If i change customNodes[1].visible = false; the node does not display as expected.

But Foo[1] Still eats space between customNodes[0] and customNodes[2] resulting in gaps between the nodes.

This can be done by doing the following statement instead:

    delete customNodes[1];

Unfortunately, I am not allowed to actually delete data from the list. Thus, need to rely on visibility

So again, Is it possible to Remove an item from the ListView by not removing it's content[] ?

if not, any suggestions on how can this be achieved?

A: 

No. But if you want it to behave like that without actually removing the list. You can add a property to your CustomNode. Then check for that property when adding data to the list.

i.e.

    var customNodes : Foo[] = [Foo{bar:"help" isDismissed : false}, 
                  Foo{bar:"me" isDismissed : true}, 
                  Foo{bar:"please" isDismissed : false}]; 

Then in your ItemList do:

    ItemList{ 
       content : bind [
                for (node in CustomNodes) 
                   if(node.isDismissed) [] else [node]
       ]
    }

This way you are not actually deleting data from customNodes but just decides which should be rendered in the ItemList.

Joopiter