Sean Schulte

Twitter: @sirsean


I'm doing a bit more Playbook development, and I wanted to be able to delete items out of a List with a button inside each item. The way to do that is by defining your own ItemRenderer.

Here's what it looks like:

Item renderer with a delete button

I'm using a ModelLocator just like the one I described in my last post about Playbook development, and I've defined a new MXML component that displays the name of the object and has a delete button in it.

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="" 
                autoDrawBackground="true" xmlns:mx="library://">

            import model.ModelLocator;
            import model.Family;

            private var modelLocator:ModelLocator = ModelLocator.getInstance();

            private var family:Family;

            public override function set data(value:Object):void {
       = value;

                family = Family(value);

            private function deleteClickHandler(event:Event):void {

And using the ItemRenderer (which I've named FamilyRenderer in this case, and placed in the views.renderer package where I've been putting all my renderers) is very simple.

The ModelLocator.removeFamily method is about what you'd expect:

public function removeFamily(family:Family):void {
    var index:int = families.getItemIndex(family);

What happens here is that when you click that delete button, we call out to the ModelLocator and tell it to remove the item that's currently being rendered. Since the entire ModelLocator is [Bindable], the change to ModelLocator.persons will update what's displayed in the familiesList, and the ItemRenderer on which you just clicked the delete button disappears.]]>