As long as you're happy...

 

I don't understand how you can expect to choose an item from a
dataprovider if the dataprovider isn't already set.  If you're seeing
the dp change before the selected item is set, that implies that you are
not setting the selectedItem in the same "script" as when the
dataprovider is set.  Flash/Flex is a deferred rendering environment.

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of markgoldin_2000
Sent: Thursday, January 10, 2008 9:14 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Setter question

 

Yes, I am basically doing the same.
But I can't agree that DP must be set first. Maybe from Flex's point 
of view it does, but not from the user's. 
If you set DP first and then load your form's data then for a short 
period of time(and maybe not really short) you will see wrong values 
(actually first items) in all your combos till form is loaded. Not 
big of a deal, but I dont like to see wrong data on the screen at all 
times.
I have got it working, it just more coding, that's all.

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> You might find this article helpful:
> 
> http://blogs.adobe.com/aharui/2008/01/selecteditem_and_combobox.html
<http://blogs.adobe.com/aharui/2008/01/selecteditem_and_combobox.html> 
> 
> 
> 
> That way you can find the item you want to be selected after the DP 
is
> set. In general the DP must be set first.
> 
> 
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>

[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of mark goldin
> Sent: Friday, January 04, 2008 3:42 AM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: RE: [flexcoders] Setter question
> 
> 
> 
> Yes, that's what I fugured.
> 
> Here is my code. 
> 
> I have a combobox as a form item.:
> 
> <mx:FormItem
> 
> label="Other RailRoad Involved" width="302"> 
> 
> <customComponents:comboItemRenderer 
> 
> selectedIndex="
> 
> {modelGeneral.otherrailroadinvolved}" 
> 
> id="
> 
> otherrailroadinvolved" width="95"! > 
> 
> </customComponents:comboItemRenderer> 
> 
> </mx:FormItem> 
> 
> dataModel tag: 
> 
> <moduleCode:accidentsGeneralModel
> 
> id="modelGeneral"/> 
> 
> 
> 
> Data Model:
> 
> public
> 
> class accidentsGeneralModel 
> 
> {
> 
> private var _otherrailroa! dinvolved:int = 0; 
> 
> [
> 
> Bindable] 
> 
> public var modelValid:Boolean = false; 
> 
> 
> 
> [
> 
> Bindable] 
> 
> public function get otherrailroadinvolved():int 
> 
> {
> 
> return! _otherrailroadinvolved; 
> 
> }
> 
> public function set
> otherrailroadinvolved(otherrailroadinvolved:int):void 
> 
> {
> 
> _otherrailroadinvolved = otherrailroadinvolved;
> 
> }
> 
> Combo's data:
> 
> combo.dataProvider = someXML;
> 
> 
> 
> Form's data:
> 
> //reference to main application
> 
> mainApp = mx.core.Application.application;
> 
> // reference to A! ccidents module 
> 
> accidentsModul! e = main App.moduleLoader.child;
> 
> accidentsModule.modelGeneral.otherrailroadinvolved =
> resultXML.general.otherrailroadinvolved;
> 
> 
> 
> Here is what happens:
> 
> If I am setting up form's data after combo's dropdown has been set 
then
> the combo will show the correct item: item that is driven by the 
form's
> data. But if I do it other way around then the combo does not show 
the
> correct one but always has its selectedIndex = 0.
> 
> I am trying to override dataProvider property but dont know what I 
can
> match combo's dropdown data to to set its selectedIndex manually.
> 
> 
> 
> Thanks
> 
> 
> Alex Harui <[EMAIL PROTECTED]> wrote: 
> 
> Unless comboItemRenderer is in a List or DataGrid or other
> ListBase-derived class, the listData setter function will not be 
called.
> 
> Assigning the combo's dataprovider just tells its dropdown List 
what to
> display.
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flex! [EMAIL PROTECTED] 
ahoogroups.com]
> On Behalf Of mark goldin
> Sent: Thursday, January 03, 2008 6:17 PM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: RE: [flexcoders] Setter question
> 
> Combo:
> 
> package! 
> 
> CustomComponents 
> 
> {
> 
> import mx.controls.*; 
> 
> import mx.controls.listClasses.*; 
> 
> import mx.collections.*; 
> 
> import flash.events.Event; 
> 
> import mx.events.*; 
> 
> public class comboIte! mRenderer extends ComboBox implements
> IDropInListItemRenderer 
> 
> {
> 
> public function! comboItemRenderer() 
> 
> { 
> 
> super(); 
> 
> }
> 
> override public function set listData(value:BaseListData):void 
> 
> {
> 
> super.listData = value; 
> 
> ......
> 
> Assigning data:
> 
> combo.dataProvider = XMLData;
> 
> Should I be getting into listData function after that command?
> 
> 
> Gordon Smith <[EMAIL PROTECTED]> wrote: 
> 
> What do you mean by defining a "set function" for the ComboBox? Can 
you
> show some code?
> 
> ! 
> 
> 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: Thursday, January 03, 2008 5:44 PM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Setter question
> 
> I have a combobox in a form. I have also defined a set function for 
> that combo. I am assigning data to the control using:
> combo.dataProvider = someXML. The data is shown with no problem, 
but 
> set function is not called. Am I doing something wrong?
> 
> Thanks
>

 

Reply via email to