--- In flexcoders@yahoogroups.com, "vincy8080" <vincy8...@...> wrote:
>
> Hi,
> 
> I'm really new at flex programming, and I'm trying to implement this
> custom datagrid component:
> 
> Column 1 and 2 would display datas based on a arraycollection
> Column 3 would display a countdown timer, counting from the value of
> column 1 to 0
> When the timer reach 0, the line should be erased from the datagrid 
(and
> the arraycollection)
> 
> What would be the best way to implement that? what do you think 
about
> custom datagrid with itemrenderer for the timer column?
> 
> Could you please just tell me in a few words how the way you would
> implement such component?

I think you have several choices for this, none of which really need 
you to extend DataGrid. 

One way is to use an itemRenderer that extends a class that 
implements IDropInListItemRenderer, which I believe label does.  I'd 
add a script tag that had a function in it that implemented the 
timer.  I'd start the timer in the override of the set data() 
function, whenever  the renderer gets any non-null data.  Once the 
timer reaches zero, you have a choice.  Since your renderer extends 
IDropInListItemRenderer, you have access to the DataGrid's 
dataProvider in the listData property.  This means that you could 
directly delete the item from the dataProvider from the renderer.  
Another is to generate an event when the timer reaches 0 and allow 
the containing application to decide what to do.  The down side of 
this is that if the datagrid scrolls at all, items that are not 
displayed will not count down.

Another way is to have the "countdown" be an actual property of the 
object itself and have a single timer in the containing app that 
counts down for all items, calling itemUpdated each time it changes 
an item.  The datagrid would simply display the collection as 
normal.  In this scenario, I probably wouldn't delete the item from 
the ArrayCollection at all, but would use a filterFunction that hides 
all items when the counter is 0.  That way you can easily reset the 
display.

Hope this gives you some ideas;

Amy



Reply via email to