I have developed a flex application where it contains an itemrenderer which displays list of items. The problem is if I select an item the background gets highlighted and if I go to another page and come back to the same page again, the item which I had selected before is still highlighted. Is there any solution that I can refresh the itemrenderer to clear the highlighted background every time when I open the page?
2 Answers
So it sounds like when you say "go to another page and come back" that you're navigating to some other screen in your app and returning to the screen that has the list. The item says selected because your view is being re-used. It's not a new view that is being created from scratch...
To remove the selection from the list, you can set the selectedIndex of the list to -1, or perhaps even set the selectedItem of the list to null
(or perhaps undefined
as the docs state). You can do either of these things right before you navigate to the next screen, or when you navigate back to the list.
There's a few more ways to solve this:
- don't re-use the view
- reset the dataProvider on the list when you navigate back
- etc...
But setting the selectedIndex
or selectedItem
would be the most efficient method.
As suggested by Sunil. Try to reset the dataprovider of the list when navigating away from the list. set list.dataProvider = new ArrayCollection(). or if you have the data list.DataProvider = arrayCollectionThatYouHave
Note: If you want the whole screens data to be refreshed every time the user opens this view in the view stack, then listen for 'show' event and reset the dataprovider and set default values in this event.