I have a grid filled with >1000 datasets. one column uses a custom itemRenderer which is used to display the value of a foreign key.
All the datasets which are displayed without scrolling are displayed with the right information. But when it comes to scrolling, some datasets will have displayed the wrong value in the itemRenderer. As far as I have understood this, it is because of the reuse of itemRenderers.
But as great as reusing might be, displaying the wrong information cannot be the result. So how do I get rid of this problem?
EDIT: I have managed to get rid of this problem, but I will post some code anyway to point my plan:
<?xml version="1.0" encoding="utf-8"?>
<mx:Script>
<![CDATA[
private var dataAccess : DataAccess = DataAccess.getInstance();
private var foreign : ArrayCollection = new ArrayCollection();
private function onCreationComplete() : void
{
dataAccess.service.getForeignDatasets.addEventListener("result", onGetForeignDatasets);
dataAccess.service.getForeignDatasets();
}
private function onGetForeignDatasets(event : ResultEvent) : void
{
foreign = event.result as ArrayCollection;
preSelect();
}
//gets the entry from the foreign entity which matches
//the foreign key in this.data
private function preSelect() : void
{
for each(var obj : Object in foreign)
{
if(obj.id == data.foreignKey))
{
value.text = obj.name;
return;
}
}
value.text = "";
}
private function onDataChange() : void
{
preSelect();
}
]]>
</mx:Script>
I left all the uneccessary code...
The code above works and resolves the problem of displaying wrong data.
Any other idea to implement this functionality?