Flex 4: Dynamically created DataGrid with custom ItemRender, problem detecting right cell
<mx:DataGrid id="calendarGrid"
dataProvider="{rows}"
width="100%"
height="100%">
<mx:columns/>
</mx:DataGrid>
I dynamically add columns and rows to it in this way:
var dgc0:DataGridColumn = new DataGridColumn("timeSlot");
dgc0.headerText="Hours";
hoursColumns=new Array();
hoursColumns.push(dgc0);
for (var i:int=7;i<21;i++)
{
var dgc:DataGridColumn = new DataGridColumn();
dgc.headerText=i+":00-"+(i+1)+":00";
dgc.itemRenderer=new ClassFactory(CustomRenderer);
hoursColumns.push(dgc);
}
calendarGrid.columns=slotsColumns;
for(var i:int =0;i<maxNum+1;i++)
{
rows.addItem({timeSlot:"Day n° "+(i+1)});
}
My CustomRenderer detects user clicks and changes the color of the selected cell. When I select one cell on, say, the first column, it is colored but if I select another cell on the same column the first one is uncolored and the second开发者_如何学C isn't colored. Maybe the same renderer is used for all cell in the column? There's a way to avoid it?
Thanks a lot.
I've got it!
Sorry my second unnecessary question :( my custom renderer constructor has this code inside:
addEventListener(FlexEvent.DATA_CHANGE, resetCell);
which reset cell color, I've remove it and now seems work... sorry again.
精彩评论