mark goldin escreveu:
> 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
>
>
>
>
> __________ NOD32 2747 (20071225) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
Not really. You just create one datagrid component. And when you insert
one object you try to execute a function (your custom code) in THE
OBJECT. If the object has that function defined it executes it, else it
fails (throwing a TypeError) and executes de default code.
Here's a sample Object you could had to the CustomDatagrid.
public class CustomObject {
private var fooCounter:int;
public function CustomObject() {
fooCounter = 0;
}
public function customFunction():void {
fooCounter++;
}
}
If you added this CustomObject to the previous CustomGrid it would
execute the /CustomObject.customFunction() /incrementing the fooCounter.
If you added any other Object not implementing customFunction() the
CustomGrid would execute the defaulte code (the one inside catch).
Hope I was clear enough,
Frederico Garcia