Not sure about #1.
I will be ading dataGrids to the main container dynamically because 
it's not known how many will be at the design time. Can I just loop 
thru my data adding dataGrids to the main HBox one by one?

--- In flexcoders@yahoogroups.com, "Gordon Smith" <[EMAIL PROTECTED]> wrote:
>
> <1. Create the internal components in an override of createChildren
()
> 
> In the main container, HBox, right?
> 
>  
> 
> Write a component, say MultiDataGrid, that extends HBox (or Canvas, 
or
> Container). In MultiDataGrid, override createChildren() to create 
the
> internal stuff (DataGrids, VBoxes if necessary, etc.)
> 
>  
> 
> <2. Write a setter for the data
> Isn't it supposed to be on internal dataGrid class since same class 
> is used for each internal dataGrid?
> 
>  
> 
> That depends on how you want to set data into the MultiDataGrid. If 
you
> want to just write
> 
>  
> 
>     mdg.dataProvider = ...;
> 
>  
> 
> and have the data magically appear in the right DataGrids (which 
seems
> like the best approach), then you'd implement a 'dataProvider' 
property
> on MultiDataGrid.
> 
>  
> 
> If that's not natural, you might decide that MultiDataGrid needs to
> publicly expose the fact that it has a bunch of DataGrids inside, 
and
> provide some way to access them. In that case, since each DataGrid
> already has a 'dataProvider' property, it wouldn't be necessary to
> override this unless the 'dataProvider' takes some weird form that
> DataGrid doesn't already understand. However, this isn't as good an
> approach, because the DataGrids won't get created until you add the
> MultiDataGrid to the display list, so you couldn't write code like
> 
>  
> 
> var mdg:MultiDataGrid = new MultiDataGrid();
> 
> mdg.getUpperDataGridAt(3).dataProvider = ...;
> 
> 
> <3. In an override of commitProperties(), ..
> of an internal dataGrid class for the same reason as #2?
> 
> 
> 
> If you go with approach where you create a 'dataProvider' property 
on
> MultiDataGrid, then the commitProperties() method of MultiDataGrid 
would
> handle taking the complete set of data which was specified for the
> entire MultiDataGrid and "commiting" various parts of it into the 
right
> individual DataGrid.
> 
>  
> 
> Gordon Smith
> 
> Adobe Flex SDK Team
> 
>  
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
> Behalf Of markgoldin_2000
> Sent: Wednesday, April 23, 2008 2:28 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: passing parameters to components
> 
>  
> 
> Alright, I see. But a bit more detail.
> <1. Create the internal components in an override of createChildren
()
> In the main container, HBox, right?
> <2. Write a setter for the data
> Isn't it supposed to be on internal dataGrid class since same class 
> is used for each internal dataGrid?
> <3. In an override of commitProperties(), ..
> of an internal dataGrid class for the same reason as #2?
> 
> Thanks a lot for help.
> 
> --- In flexcoders@yahoogroups.com <mailto:flexcoders%
40yahoogroups.com>
> , "Gordon Smith" <gosmith@> wrote:
> >
> > Why Canvas? Why not a VBox to hold the two DataGrids?
> > 
> > 
> > 
> > Or use a single horizontally-scrolling Canvas and put the 
DataGrids 
> at
> > the correct locations. Then you don't need any HBoxes or VBoxes.
> > 
> > 
> > 
> > In any case, you probably don't want to create the
> > Canvases/VBoxes/DataGrids based on the data, because every time 
the 
> data
> > changes you'll waste time getting rid of them and creating new 
> ones. If
> > the number of columns (or an upper bound) is know, the normal 
> process is
> > 
> > 
> > 
> > 1. Create the internal components in an override of createChildren
()
> > (after calling the supermethod).
> > 
> > 
> > 
> > 2. Write a setter for the data.
> > 
> > 
> > 
> > 3. In an override of commitProperties(), call the supermethod and 
> then
> > stuff the internal components with the data. If necessary, hide 
> extra
> > ones that aren't needed.
> > 
> > 
> > 
> > Gordon Smith
> > 
> > Adobe Flex SDK Team
> > 
> > 
> > 
> > ________________________________
> > 
> > From: flexcoders@yahoogroups.com <mailto:flexcoders%
40yahoogroups.com>
> 
> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%
40yahoogroups.com>
> ] On
> > Behalf Of markgoldin_2000
> > Sent: Wednesday, April 23, 2008 1:56 PM
> > To: flexcoders@yahoogroups.com <mailto:flexcoders%
40yahoogroups.com> 
> > Subject: [flexcoders] Re: passing parameters to components
> > 
> > 
> > 
> > That's is going to be my next step.
> > Loop thru my data and add canvas from left to right.
> > 
> > --- In flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>  <mailto:flexcoders%
> 40yahoogroups.com>
> > , "Gordon Smith" <gosmith@> wrote:
> > >
> > > Why aren't you just using a horizontally-scrolling HBox?
> > > 
> > > 
> > > 
> > > - Gordon
> > > 
> > > 
> > > 
> > > ________________________________
> > > 
> > > From: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>  <mailto:flexcoders%
> 40yahoogroups.com>
> > 
> > [mailto:flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>  <mailto:flexcoders%
> 40yahoogroups.com>
> > ] On
> > > Behalf Of markgoldin_2000
> > > Sent: Wednesday, April 23, 2008 1:43 PM
> > > To: flexcoders@yahoogroups.com <mailto:flexcoders%
40yahoogroups.com>
> <mailto:flexcoders%
> 40yahoogroups.com> 
> > > Subject: [flexcoders] Re: passing parameters to components
> > > 
> > > 
> > > 
> > > What I am trying to do is bit different.
> > > I am trying to build a dataGrid with one row and about 15-20 
> > columns.
> > > Each column would have a custom renderer based on canvas (based 
> > > UIComponent did not work for me). Then in canvas I will have 
two 
> > > dataGrids positioned vertically. Actual usser data is going to 
be 
> > > shown in internal grids. Data behind the main grid (the one 
with 
> > one 
> > > row) is unrelated to anything: I am assigning simple data to it 
> > just 
> > > to make things work. Building process flow here is something 
like 
> > > this:
> > > A custom renderer (canvas with two grids) is instantiated. The 
I 
> > need 
> > > to run some code within canvas to prepare both grids showing 
data 
> > > related to outer grid's column.
> > > I am using dataGrid for main comtainer basically to have 
> everyting 
> > > look nice (just like it would have been loking if it could have 
> > been 
> > > possible to create a dataGrid without internal 
grids/renderers), 
> > > scrolling at the same time, ....
> > > I am open for solution how to replace main dataGrid to another 
> > > container and fill it with canvas that carries two grids inside.
> > > Sorry, if it is not too clear. If I knew how to upload an image 
> of 
> > my 
> > > project I would.
> > > 
> > > Thanks for help.
> > > 
> > > --- In flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%
> > 40yahoogroups.com>
> > > , "Gordon Smith" <gosmith@> wrote:
> > > >
> > > > Setting the itemRenderer property doesn't actually add a 
> renderer 
> > to
> > > > List (or whatever) at that moment. It simply tells the 
> > List, "when 
> > > you
> > > > need to make item renderers, use this IFactory to make the 
> > renderer
> > > > instances". The List is in charge of creating item renderers, 
> not 
> > > you.
> > > > 
> > > > 
> > > > 
> > > > If you really need to cause properties to be set on the item 
> > > renderers
> > > > (as opposed to conveying those properties through the data 
> items 
> > in 
> > > the
> > > > data provider), then set the itemRenderer to a ClassFactory 
> > > instance on
> > > > which you've specified a 'properties' Object. The name/value 
> > pairs 
> > > in
> > > > the 'properties' Object will get set on each renderer when it 
is
> > > > created.
> > > > 
> > > > 
> > > > 
> > > > Gordon Smith
> > > > 
> > > > Adobe Flex SDK Team 
> > > > 
> > > > 
> > > > 
> > > > ________________________________
> > > > 
> > > > From: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%
> > 40yahoogroups.com>
> > > 
> > > [mailto:flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%
> > 40yahoogroups.com>
> > > ] On
> > > > Behalf Of markgoldin_2000
> > > > Sent: Wednesday, April 23, 2008 5:28 AM
> > > > To: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>  <mailto:flexcoders%
> 40yahoogroups.com>
> > <mailto:flexcoders%
> > 40yahoogroups.com> 
> > > > Subject: [flexcoders] Re: passing parameters to components
> > > > 
> > > > 
> > > > 
> > > > Speaking about Communicating between Components. In reality 
> > > > everything is custom, specifically custom renderers. What I 
> have 
> > > been 
> > > > having problem with is to how to populate properties of a 
> custom 
> > > > component and how to execute its methods before the component 
> is 
> > > > added to a parent container, another words before this:
> > > > Column.itemRenderer = customRenderer;
> > > > 
> > > > --- In flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com> 
> > > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%
> > > 40yahoogroups.com>
> > > > , "Tracy Spratt" <tspratt@> wrote:
> > > > >
> > > > > There are many ways. Below is a document I started, but 
have 
> not
> > > > > polished, but should be of some use.
> > > > > 
> > > > > Tracy
> > > > > 
> > > > > 
> > > > > 
> > > > > Communicating between Components:
> > > > > 
> > > > > 
> > > > > 
> > > > > Note: for "loose coupling" use events. But that is another 
> > topic.
> > > > > 
> > > > > 
> > > > > 
> > > > > A non-trivial flex application is "component" based. While 
> all 
> > of 
> > > > the
> > > > > built-in controls are components, the question of 
> communicating 
> > > > between
> > > > > components most often arises when you are using a custom 
> > > component. 
> > > > A
> > > > > custom component, whether implemented in mxml or 
> ActionScript, 
> > > has 
> > > > its
> > > > > own "scope". Within that component (Application is a 
> component 
> > > > too!),
> > > > > all sibling child controls share the same scope, so you can 
> > refer 
> > > to
> > > > > controls by their id. If the controls(components) have 
public
> > > > > properties or methods, you can reference those members 
> directly 
> > > > through
> > > > > the id:
> > > > > 
> > > > > <mx:TextInput id="textinput1" text="test value" .../>
> > > > > 
> > > > > <mx:Text id="text1" ... text="{textinput1.text}" .../>
> > > > > 
> > > > > 
> > > > > 
> > > > > Ok, so far, its a "duh" right?
> > > > > 
> > > > > 
> > > > > 
> > > > > When you use custom components in a Flex app, at run time 
> they 
> > > make 
> > > > a
> > > > > document object model hierarchy (DOM). Each subcomponent 
has 
> > its 
> > > > own
> > > > > scope and code within that component can't *directly* 
> reference 
> > > the
> > > > > member properties or methods of its sibling subcomponents.
> > > > > 
> > > > > 
> > > > > 
> > > > > So again, within a component, code can reference children 
> > > > directly, as
> > > > > in the example above. But there are two other cases 
inherent 
> in 
> > a
> > > > > hierarchy. You might want to reference "up", to get to 
public 
> > > > members
> > > > > of the parent, grandparent, etc, or 'down", to get to 
> > > > a "grandchild".
> > > > > 
> > > > > 
> > > > > 
> > > > > Accessing members in the parent:
> > > > > 
> > > > > On an ordinary component DOM, you can reference the parent 
> > > component
> > > > > using the .parent property. Say that a control with 
> > > id="textinput1"
> > > > > exists in the parent of the current component. then you 
could 
> > do:
> > > > > 
> > > > > <mx:Text id="text1" ... text="{parent.textinput1.text}"
> > > > > .../>
> > > > > 
> > > > > 
> > > > > 
> > > > > Accessing members in the main application:
> > > > > 
> > > > > Components can be nested, sometimes very deeply. If the 
> > reference 
> > > > you
> > > > > want is all the way at the top-level, main application (the 
> one 
> > > > with the
> > > > > <mx:Application> tag), you could do
> > > > > {parent.parent.parent.textinput1.text}, but you would have 
to 
> > > count 
> > > > the
> > > > > component levels just right. Instead, you can use
> > > > > Application.application to get to that scope:
> > > > > 
> > > > > <mx:Text id="text1" ...
> > > > > text="{Application.application.textinput1.text}" .../>
> > > > > 
> > > > > You can shoretn this style of reference by importing
> > > > > mx.core.Application, and assigning Application.application 
to 
> a
> > > > > variable, like _app, the doing (_app.textinput1.text)
> > > > > 
> > > > > 
> > > > > 
> > > > > Accessing components of a child component ("grandchildren"):
> > > > > 
> > > > > Say that in this case, a child component has the TextInput 
> > > control 
> > > > you
> > > > > want to reference. First, make sure the child component has 
> an 
> > id:
> > > > > 
> > > > > <myComp:MyCustomComp id="mycc1" .../>
> > > > > 
> > > > > Then, in the same scope (the same component/file that 
> > > > contains "mycc1"
> > > > > above) you can say:
> > > > > 
> > > > > <mx:Text id="text1" ... 
> > > > text="{mycc1.textinput1.text}" .../>
> > > > > 
> > > > > 
> > > > > 
> > > > > Accessing a nested component:
> > > > > 
> > > > > As mentioned above you can go "up" the hierarchy using
> > > > > "parent.parent...". You can also go "down" the hirearchy 
> using 
> > id
> > > > > references:
> > > > > 
> > > > > <mx:Text id="text1" ...
> > > > > text="{mycc1.mycc11.mycc.12.textinput1.text}" .../>
> > > > > 
> > > > > 
> > > > > 
> > > > > Additional notes:
> > > > > 
> > > > > If you are using SWFLoader to load an entire Application, 
you 
> > can
> > > > > reference the immediate parent application 
> > > using "parentDocument". 
> > > > You
> > > > > can also use Application.application to reach the main app, 
> as 
> > > shown
> > > > > above.
> > > > > 
> > > > > 
> > > > > 
> > > > > Accessing members of an application loaded by SWFLoader is 
a 
> > bit 
> > > > more
> > > > > complicated. See the example here:
> > > > > 
> > > > > http://www.cflex.net/showFileDetails.cfm?ObjectID=690
> <http://www.cflex.net/showFileDetails.cfm?ObjectID=690> 
> > <http://www.cflex.net/showFileDetails.cfm?ObjectID=690
> <http://www.cflex.net/showFileDetails.cfm?ObjectID=690> > 
> > > <http://www.cflex.net/showFileDetails.cfm?ObjectID=690
> <http://www.cflex.net/showFileDetails.cfm?ObjectID=690> 
> > <http://www.cflex.net/showFileDetails.cfm?ObjectID=690
> <http://www.cflex.net/showFileDetails.cfm?ObjectID=690> > > 
> > > > <http://www.cflex.net/showFileDetails.cfm?ObjectID=690
> <http://www.cflex.net/showFileDetails.cfm?ObjectID=690> 
> > <http://www.cflex.net/showFileDetails.cfm?ObjectID=690
> <http://www.cflex.net/showFileDetails.cfm?ObjectID=690> > 
> > > <http://www.cflex.net/showFileDetails.cfm?ObjectID=690
> <http://www.cflex.net/showFileDetails.cfm?ObjectID=690> 
> > <http://www.cflex.net/showFileDetails.cfm?ObjectID=690
> <http://www.cflex.net/showFileDetails.cfm?ObjectID=690> > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > ________________________________
> > > > > 
> > > > > From: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com> 
> > > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%
> > > 40yahoogroups.com>
> > > > 
> > > > [mailto:flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com> 
> > > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%
> > > 40yahoogroups.com>
> > > > ] On
> > > > > Behalf Of Luke Vanderfluit
> > > > > Sent: Tuesday, April 22, 2008 7:08 PM
> > > > > To: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%
> > 40yahoogroups.com>
> > > <mailto:flexcoders%
> > > 40yahoogroups.com> 
> > > > > Subject: [flexcoders] passing parameters to components
> > > > > 
> > > > > 
> > > > > 
> > > > > Hi.
> > > > > 
> > > > > I have a flex application that gets called from an html 
link 
> > and 
> > > is
> > > > > passed a 
> > > > > parameter. The param is personid.
> > > > > 
> > > > > I retrieve the parameter in the flex application 
> > (BrowserManager).
> > > > > So I have access to it in the main application file.
> > > > > 
> > > > > I have a number of components within the main application, 
> that 
> > do
> > > > > server 
> > > > > requests. In some of those requests I need to pass the 
> personid 
> > > > (that I
> > > > > have 
> > > > > retrieved from the browser url).
> > > > > 
> > > > > My question is:
> > > > > 
> > > > > What is the accepted method of passing variables (params) 
> > between
> > > > > components, 
> > > > > specifically, in this case, from parent to child component?
> > > > > 
> > > > > Thanks for your responses.
> > > > > 
> > > > > Kind regards.
> > > > > Luke.
> > > > > 
> > > > > -- 
> > > > > Luke Vanderfluit
> > > > > Analyst / Web Programmer
> > > > > e3Learning.com.au
> > > > > 08 8221 6422
> > > > >
> > > >
> > >
> >
>


Reply via email to