Look at how labelFunction is implemented.  You supply a custom function
that gets called under certain circumstances.
 
Others use events.  It is more object-oriented IMHO.

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of mark goldin
Sent: Wednesday, December 26, 2007 1:03 PM
To: [email protected]
Subject: Re: [flexcoders] Reusability question



I think I understand what you are saying.
But I am already extending Flex' s native DataGrid. I thought I could
have added a custom method somehow without creating as many classes as
many grids I am going to have in my project. Am I understanding you
correctly? I will need to extend my base DataGrid for each object in my
project?

Frederico Garcia <[EMAIL PROTECTED]> wrote:

        mark goldin escreveu:
        > Yes, I can create a generic method for my Grid:
        > public function doSomethingAfterRowIsAdded():void
        > {
        > }
        > But I can't have any code there because it is specific to an
object 
        > instatiation.
        >
        >
        > */Frederico Garcia <[EMAIL PROTECTED]
<mailto:fmotagarcia%40kemelyon.com> >/* wrote:
        >
        > markgoldin_2000 escreveu:
        > > I am designing a custom ListGrid. Most of functionality will
be
        > in the
        > > base class. But some will deppend on a specific
instatiation. For
        > > example, when new row is added to the ListGrid I need to run
        > additional
        > > code for each object being instatiated from the base class.
And
        > that
        > > code is unique for each object. Any idea how set this up
properly
        > > meaning keeping everything as generic as possible.
        > >
        > > Thanks
        > >
        > >
        > >
        > > --
        > > Flexcoders Mailing List
        > > FAQ:
        >
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt> 
        >
<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt> >
        > > Search Archives:
        > http://www.mail-archive.com/flexcoders%40yahoogroups.com
<http://www.mail-archive.com/flexcoders%40yahoogroups.com> 
        > <http://www.mail-archive.com/flexcoders%40yahoogroups.com
<http://www.mail-archive.com/flexcoders%40yahoogroups.com> >
        > > Yahoo! Groups Links
        > >
        > >
        > >
        > >
        > > __________ NOD32 2747 (20071225) Information __________
        > >
        > > This message was checked by NOD32 antivirus system.
        > > http:! //www.eset.com <http://www.eset.com/>
<http://www.eset.com/ <http://www.eset.com/> >
        > >
        > >
        > >
        > >
        > Maybe you could create a function on every object always with
the
        > same
        > name, and when you had a object to the list you check if th
function
        > exists. If it does you execute it, else you do nothing. You
can
        > see the
        > same principle in clonable objects (having a function called
        > /clone()/)
        >
        > Regards,
        >
        > Frederico Garcia
        >
        >
        > 
        >
        > __________ NOD32 2747 (20071225) Information __________
        >
        > This message was checked by NOD32 antivirus system.
        > http://www.eset.com <http://www.eset.com/> 
        What I meant was having a function on the Object added to the
grid, not 
        on the grid itself. Something like this:
        
        public class CustomGrid extends DataGrid {
        
        (...)
        
        override public function addElement(value:Object):void {
        super.addElement(value);
        executeCustomCode(value);
        }
        
        public function executeCustomCode(value:Object):void {
        try {
        value.customFunction();
        }
        catch(error:TypeError) {
        // ADD YOUR DEFAULT CODE HERE
        }
        }
        }
        
        The syntax is not correct but it gives you the big picture. To
improve 
        this you could had a listener on /added/ to the dataProvider
that 
        triggered the executeCustomCode function.
        
        Hope this helps,
        
        Frederico Garcia
        


 

Reply via email to