[flexcoders] Re: Removing ArrayCollection item from within ItemRenderer
Hi Barry, Sorry to laugh a little, but parent.removeChild(this), is actually removing the itemRenderer display object; and leaving a hole in the TileList. There are a few ways to remove list items; from within an itemRenderer. But, most of them involve referencing the list's dataProvider directly; using something like: myArrayCollection.removeItemAt(myTileList.selectedIndex); Now, how do you get to the dataProvider from within the itemRenderer. Probably the best way is to dispatch an event when the delete button is clicked. Using events takes advantage of loose coupling. Listen for the event in the class that contains the TileList and remove the item from the dataProvider. Depending on how you have it setup, chances are that when you click the button inside the itemRenderer, the TileList's selected item and index will change automatically. Another way, if you want to get dirty, is to do something like this on the click event of the delete button: this.parentDocument.myTileList.dataProvider.removeItemAt(listData.rowInd\ ex); -TH --- In flexcoders@yahoogroups.com, calisza [EMAIL PROTECTED] wrote: After having a look around at various blogs, resources etc I'm stumped on the following : I have a TileList using a custom itemRenderer. The dataprovider is a standard ArrayCollection of objects. The itemRenderer contains an Image, a Label and a Button. When the user clicks the button - I want to remove that particular item from both the Tilelist and the dataProvider. The problem is that parent.removeChild(this) only works partially (it clears the tilelist block of the item's content, but the empty block remains in place... still highlighted). I also have no idea how to access the dataProvider from within the itemRenderer. parent.dataProvider and owner.dataProvider don't seem to work, my guess being that dataProvider is a private property. Any ideas ? Is there perhaps a better way of doing this ? (still new to flex so still learning). TIA, Barry
[flexcoders] Re: Removing ArrayCollection item from within ItemRenderer
--- In flexcoders@yahoogroups.com, calisza [EMAIL PROTECTED] wrote: After having a look around at various blogs, resources etc I'm stumped on the following : I have a TileList using a custom itemRenderer. The dataprovider is a standard ArrayCollection of objects. The itemRenderer contains an Image, a Label and a Button. When the user clicks the button - I want to remove that particular item from both the Tilelist and the dataProvider. The problem is that parent.removeChild(this) only works partially (it clears the tilelist block of the item's content, but the empty block remains in place... still highlighted). I also have no idea how to access the dataProvider from within the itemRenderer. parent.dataProvider and owner.dataProvider don't seem to work, my guess being that dataProvider is a private property. Any ideas ? Is there perhaps a better way of doing this ? (still new to flex so still learning). TIA, Barry Hi Try using the 'outterDocument' keyword when u access some data inside an item render Roops
[flexcoders] Re: Removing ArrayCollection item from within ItemRenderer
--- In flexcoders@yahoogroups.com, calisza [EMAIL PROTECTED] wrote: After having a look around at various blogs, resources etc I'm stumped on the following : I have a TileList using a custom itemRenderer. The dataprovider is a standard ArrayCollection of objects. The itemRenderer contains an Image, a Label and a Button. When the user clicks the button - I want to remove that particular item from both the Tilelist and the dataProvider. The problem is that parent.removeChild(this) only works partially (it clears the tilelist block of the item's content, but the empty block remains in place... still highlighted). I also have no idea how to access the dataProvider from within the itemRenderer. parent.dataProvider and owner.dataProvider don't seem to work, my guess being that dataProvider is a private property. Any ideas ? Is there perhaps a better way of doing this ? (still new to flex so still learning). Dispatch an event from the itemRenderer that you listen for in the main document, and then remove the selectedItem from the ArrayCollection. The click on the button should also select the renderer. HTH; Amy
[flexcoders] Re: Removing ArrayCollection item from within ItemRenderer
Hi Tim, Thanks so much, your tips did the trick. I'm going to go the whole event dispatching route, but it's good to know how to access the parentDocument elements. And ditto on the removeChild bit - i had to laugh at myself when I read your response - it's how we learn :) thanks again, B --- In flexcoders@yahoogroups.com, Tim Hoff [EMAIL PROTECTED] wrote: Hi Barry, Sorry to laugh a little, but parent.removeChild(this), is actually removing the itemRenderer display object; and leaving a hole in the TileList. There are a few ways to remove list items; from within an itemRenderer. But, most of them involve referencing the list's dataProvider directly; using something like: myArrayCollection.removeItemAt(myTileList.selectedIndex); Now, how do you get to the dataProvider from within the itemRenderer. Probably the best way is to dispatch an event when the delete button is clicked. Using events takes advantage of loose coupling. Listen for the event in the class that contains the TileList and remove the item from the dataProvider. Depending on how you have it setup, chances are that when you click the button inside the itemRenderer, the TileList's selected item and index will change automatically. Another way, if you want to get dirty, is to do something like this on the click event of the delete button: this.parentDocument.myTileList.dataProvider.removeItemAt(listData.rowInd\ ex); -TH --- In flexcoders@yahoogroups.com, calisza barry@ wrote: After having a look around at various blogs, resources etc I'm stumped on the following : I have a TileList using a custom itemRenderer. The dataprovider is a standard ArrayCollection of objects. The itemRenderer contains an Image, a Label and a Button. When the user clicks the button - I want to remove that particular item from both the Tilelist and the dataProvider. The problem is that parent.removeChild(this) only works partially (it clears the tilelist block of the item's content, but the empty block remains in place... still highlighted). I also have no idea how to access the dataProvider from within the itemRenderer. parent.dataProvider and owner.dataProvider don't seem to work, my guess being that dataProvider is a private property. Any ideas ? Is there perhaps a better way of doing this ? (still new to flex so still learning). TIA, Barry