Thanks a lot again :-)
In fact I managed to have my solution working as well:
Defined a custom DataGridColumn:
class com.r0main.ComboBoxDataGridColumn extends
mx.controls.gridclasses.DataGridColumn {
[ChangeEvent("dataProviderChanged")]
private var _dataProvider:Array;
public function get dataProvider():Array {
return _dataProvider;
}
public function set dataProvider(newDp:Array) {
_dataProvider = newDp;
dispatchEvent( { type: "dataProviderChanged" } );
}
}
Then in my ComboBoxCellRenderer:
columnOwner =
ComboBoxDataGridColumn(DataGrid(listOwner).columns[getCellIndex().columnIndex]);
// get values immediately
dataProvider = olumnOwner.dataProvider;
// if any later change to DataProvider
columnOwner.addEventListener("dataProviderChanged", this);
This does perfectly what I needed, I can now set many dataProviders to
many ComboBox cell-renderers [in fact my ComboBox cell-renderer is
more complex, because 90% of time it displays a simple Label, but on
click it popups a ComboBox]
r0main
--- In [email protected], "Alistair McLeod" <[EMAIL PROTECTED]> wrote:
> Hi r0main,
>
> I've just realised that you don't need to set the columnName to
0,1,2 etc on
> the individual columns. Instead of getDataLabel(), use
> getCellIndex().columnIndex - it'll do the same thing.
>
> Cheers,
>
> Ali
>
>
> --
> Alistair McLeod
> Development Director
> iteration::two
>
> [EMAIL PROTECTED]
> Office: +44 (0)131 338 6108
>
> This e-mail and any associated attachments transmitted with it may
contain
> confidential information and must not be copied, or disclosed, or
used by
> anyone other than the intended recipient(s). If you are not the intended
> recipient(s) please destroy this e-mail, and any copies of it,
immediately.
>
> Please also note that while software systems have been used to try
to ensure
> that this e-mail has been swept for viruses, iteration::two do not
accept
> responsibility for any damage or loss caused in respect of any viruses
> transmitted by the e-mail. Please ensure your own checks are carried out
> before any attachments are opened.
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of r0main
> Sent: 10 August 2005 12:26
> To: [email protected]
> Subject: [flexcoders] Re: Multiples ComboBox Cell Renderers ?
>
> Thanks Ali,
> that's a good idea, simple... I'll still investigate my second
option for
> few minutes then I'll use your solution :-).
>
> Ciao, r0main
>
> --- In [email protected], "Alistair McLeod" <[EMAIL PROTECTED]>
wrote:
> > Hi r0main,
> >
> >
> >
> > There's a 3rd way, and it's what I've done in the past...
> >
> >
> >
> > What you do is have a single data provider, but each element in the
> > data provider is itself an array of whatever you want. Lets keep
it as
> > simple strings for now, but you can use objects.
> >
> >
> >
> > So, your data provider could be something like the following array:
> >
> >
> >
> > [ [ "Row0Column0", "Row0Column1", "Row0Column2" ]
> >
> > [ "Row1Column0", "Row1Column1", "Row1Column2" ]
> >
> > [ "Row2Column0", "Row2Column1", "Row2Column2" ] ]
> >
> >
> >
> >
> >
> > Then, on each datagrid column, you set the columnName to a column
> index, ie.
> > 0, 1, and 2. This is what is returned by getDataLabel() in your
> custom cell
> > renderer, as you'll see below.
> >
> >
> >
> > In your custom cell renderer setValue, do something like this:
> >
> >
> >
> > public function setValue( str : String, item : Object, selection :
> String )
> > {
> >
> > ...
> >
> > var text : String = String( item[ getDataLabel() ] );
> >
> > ...
> >
> > }
> >
> >
> >
> > text will thereafter hold Row0Column0 etc.
> >
> >
> >
> > This is typed from memory, so may not be exact, but it should get
> you there.
> >
> >
> >
> > Cheers,
> >
> >
> >
> > Ali
> >
> >
> >
> > --
> >
> > Alistair McLeod
> >
> > Development Director
> >
> > iteration::two
> >
> >
> >
> > [EMAIL PROTECTED]
> >
> > Office: +44 (0)131 338 6108
> >
> >
> >
> > This e-mail and any associated attachments transmitted with it may
> contain
> > confidential information and must not be copied, or disclosed, or
> used by
> > anyone other than the intended recipient(s). If you are not the
> > intended
> > recipient(s) please destroy this e-mail, and any copies of it,
> immediately.
> >
> >
> >
> > Please also note that while software systems have been used to try
> to ensure
> > that this e-mail has been swept for viruses, iteration::two do not
> accept
> > responsibility for any damage or loss caused in respect of any
viruses
> > transmitted by the e-mail. Please ensure your own checks are carried
> > out before any attachments are opened.
> >
> > -----Original Message-----
> > From: [email protected] [mailto:[EMAIL PROTECTED]
> > On Behalf Of r0main
> > Sent: 10 August 2005 09:05
> > To: [email protected]
> > Subject: [flexcoders] Multiples ComboBox Cell Renderers ?
> >
> >
> >
> > Hi flexcoders,
> >
> > in a single DataGrid I need to use in 3 columns 3 "instances" of
> >
> > ComboBox-based CellRenderers, that is 100% same functionnalities,
> >
> > except from the ComboBox's data provider [different lists]. Yet I was
> >
> > using a static dataProvider in my cellRenderer class, but I can't with
> >
> > 3 ComboBox having different content being in the same screen.
> >
> >
> >
> > Option 1: I do 3 different ComboBoxCellRenderer classes
> >
> > [ComboBoxCellRenderer1, ComboBoxCellRenderer2, ComboBoxCellRenderer3],
> >
> > which is what I try to avoid
> >
> >
> >
> > Option 2: I find a suitable way to define at DataGridColumn-level the
> >
> > dataProvider to us for ComboBoxcellRenderers of this column, so each
> >
> > column can have its own dataProvider to fill ComboBoxes. And a
> >
> > suitable way to get those dataProvider from inside the CellRenderer...
> >
> >
> >
> > Anyone having some Option 2 code sample ? Thanks a lot !!!
> >
> >
> >
> > r0main
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > ------------------------ Yahoo! Groups Sponsor
> > --------------------~-->
> >
> > <font face=arial size=-1><a
> >
>
href="http://us.ard.yahoo.com/SIG=12hc57p3q/M=362329.6886308.7839368.1510227
> >
>
/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123668296/A=2894321/R=0/SIG=11dvsfulr
> > /*http://youthnoise.com/page.php?page_id=1992
> >
> > ">Fair play? Video games influencing politics. Click and talk
> > back!</a>.</font>
> >
> > --------------------------------------------------------------------~-
> > >
> >
> >
> >
> > --
> >
> > Flexcoders Mailing List
> >
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> >
> > Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com
> >
> > Yahoo! Groups Links
> >
> >
> >
> > http://groups.yahoo.com/group/flexcoders/
> >
> >
> >
> > [EMAIL PROTECTED]
> >
> >
> >
> > http://docs.yahoo.com/info/terms/
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor --------------------~-->
> <font face=arial size=-1><a
>
href="http://us.ard.yahoo.com/SIG=12hrp9hge/M=362335.6886445.7839731.1510227
>
/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123680348/A=2894361/R=0/SIG=13jmebhbo
>
/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO
> &cmpgn=GRP&RTP=http://groups.yahoo.com/">In low income
neighborhoods, 84% do
> not own computers. At Network for Good, help bridge the Digital
> Divide!</a>.</font>
> --------------------------------------------------------------------~->
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12hh1lhk5/M=362131.6882499.7825260.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123686249/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~->
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/