Also this returns null
Alert.show(MyModel.getInstance().SelectedBudgetVO.amount.toString());
(trying it right after assigned the event.target.selectedItem to the
SelectedBudgetVO)
On Tue, Oct 7, 2008 at 10:30 AM, Greg Morphis <[EMAIL PROTECTED]> wrote:
> I don't think something is firing..
> I had it working with the other code.. creating the empty VO and
> assigning the values one by one and then passing the VO to the command
> to populate the MyModel SelectedVO..
> When I chose a row a form I had started populating using this:
> {MyModel.getInstance().SelectedBudgetVO.amount.toString()}
>
> but when I changed the changeHandler to just
> MyModel.getInstance().SelectedBudgetVO = event.target.selectedItem as
> BudgetVO;
>
> They stopped populating
>
>
> On Tue, Oct 7, 2008 at 10:17 AM, Tim Hoff <[EMAIL PROTECTED]> wrote:
>> "I have no idea why it wont work with an ArrayCollection"
>>
>> Because your ArrayCollection is a collection of VO's, not a collection of
>> ArrayCollections; although there may be ArrayCollections as properties of
>> the VO. Can you not just do this?
>>
>> MyModel.getInstance().SelectedBudgetVO = event.target.selectedItem as
>> BudgetVO;
>>
>> -TH
>>
>> --- In [email protected], "Greg Morphis" <[EMAIL PROTECTED]> wrote:
>>>
>>> I changed it to using a VO and it works..
>>>
>>> MyModel.getInstance().SelectedBudgetVO = (event as BudgetEvent).budget;
>>>
>>> //Alert.show(MyModel.getInstance().Budget.amount.toString());
>>>
>>> I have no idea why it wont work with an ArrayCollection, but it works
>>> as a VO.. not sure if this is best practice or not
>>>
>>> On Tue, Oct 7, 2008 at 9:41 AM, Greg Morphis [EMAIL PROTECTED] wrote:
>>> > This is F'ed up...
>>> >
>>> > I changed my code to this...
>>> >
>>> > public function handleChangeEvent(event:Event):void
>>> > {
>>> > var myVO:BudgetVO = new BudgetVO();
>>> > myVO.actiondate = event.target.selectedItem.actiondate;
>>> > myVO.amount = event.target.selectedItem.amount;
>>> > myVO.id = event.target.selectedItem.id;
>>> > ...
>>> >
>>> > var evt:BudgetEvent = new BudgetEvent(myVO,
>>> > MyControl.EVENT_GET_BUDGET_DETAILS);
>>> > CairngormEventDispatcher.getInstance().dispatchEvent(evt);
>>> >
>>> > }
>>> >
>>> > public class GetBudgetDetailsCommand implements ICommand, IResponder
>>> > {
>>> >
>>> > private var currentSelectedVO:BudgetVO = null;
>>> >
>>> > public function execute(event:CairngormEvent):void {
>>> >
>>> > MyModel.getInstance().SelectedBudgetAC = (event as BudgetEvent).budget
>>> > as ArrayCollection;
>>> >
>>> > /* If I Alert the (event as BudgetEvent).budget.amount.toString() I
>>> > get the amount
>>> >
>>> > But if I Alert
>>> > MyModel.getInstance().SelectedBudgetAC.getItemAt(0).amount.toString()
>>> > I get a null error.. matter of fact if I Alert
>>> > MyModel.getInstance().SelectedBudgetAC.toString()
>>> > I get a null error.. so where the hell is my data going? MyModel.as is
>>> > being imported into the command.
>>> >
>>> > import com.model.MyModel
>>> >
>>> > Again, inside MyModel.as I have the global vars..
>>> >
>>> > public var SelectedBudgetAC:ArrayCollection;
>>> >
>>> > to check to make sure the MyModel was loading properly I added another
>>> > var to it..
>>> >
>>> > public var fooVar:Number = 0;
>>> >
>>> > And if I alert that value in the execute() function, it Alerts "0" as
>>> > it should..
>>> > I'm lost
>>> > */
>>> > Alert.show(MyModel.getInstance().fooVar.toString());
>>> >
>>> > }
>>> > ....
>>> >
>>> >
>>> >
>>> > On Tue, Oct 7, 2008 at 8:28 AM, Greg Morphis [EMAIL PROTECTED] wrote:
>>> >> Still null....
>>> >>
>>> >> The DataGrid looks like
>>> >> <mx:DataGrid id="dg" width="100%"
>>> >> height="100%" dataProvider="{MyModel.getInstance().BudgetAC}"
>>> >> click="clickHandler(event);"
>>> >> change="handleChangeEvent(event as DataGridEvent);">
>>> >>
>>> >>
>>> >> Data loads fine in the grid.. cool.. The change event fires and
>>> >>
>>> >> public function handleChangeEvent(event:Event):void
>>> >> {
>>> >> MyModel.getInstance().SelectedBudgetAC = event.target.selectedItem
>>> >> as ArrayCollection;
>>> >> Alert.show(event.target.selectedItem.amount.toString());
>>> >>
>>> >> Alert.show(MyModel.getInstance().SelectedBudgetAC.getItemAt(0).toString());
>>> >>
>>> >> var evt:CairngormEvent = new
>>> >> CairngormEvent(MyControl.EVENT_GET_BUDGET_DETAILS);
>>> >> CairngormEventDispatcher.getInstance().dispatchEvent(evt);
>>> >>
>>> >> }
>>> >>
>>> >> I just don't get it.. the first Alert works and I see the amount of
>>> >> the selectedItem, but the second gives a null error..
>>> >> TypeError: Error #1009: Cannot access a property or method of a null
>>> >> object reference.
>>> >> at com.view::budgetBook/handleChangeEvent()
>>> >> at com.view::budgetBook/__dg_change()
>>> >> at flash.events::EventDispatcher/dispatchEventFunction()
>>> >> at flash.events::EventDispatcher/dispatchEvent()
>>> >> at mx.controls.listClasses::ListBase/mouseUpHandler()
>>> >> at mx.controls::DataGrid/mouseUpHandler()
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> On Tue, Oct 7, 2008 at 7:37 AM, jitendra jain
>>> >> [EMAIL PROTECTED] wrote:
>>> >>> Use event.target.selectedItems instead of event.target.selectedItem
>>> >>>
>>> >>> Thanks,
>>> >>>
>>> >>> with Regards,
>>> >>> Jitendra Jain
>>> >>>
>>> >>>
>>> >>> ----- Original Message ----
>>> >>> From: Greg Morphis [EMAIL PROTECTED]
>>> >>> To: [email protected]
>>> >>> Sent: Tuesday, 7 October, 2008 7:22:23 AM
>>> >>> Subject: Re: [flexcoders] handling data within a datagrid
>>> >>>
>>> >>> That was a typo instead of copying and pasting..
>>> >>> mySelectedRow is an ArrayCollection
>>> >>> I'm assignin the event.target. selectedItem which is a datagrid row to
>>> >>> it..
>>> >>> I want to knmow why it's not working the way it should...
>>> >>>
>>> >>> To learn I'm creating a budgetbook of sorts.. so here's what I have
>>> >>> copied and pasted..
>>> >>>
>>> >>> public function handleChangeEvent( event:DataGridEv ent):void
>>> >>> {
>>> >>> MyModel.getInstance ().SelectedBudge tAC = event.target. selectedItem
>>> >>> as
>>> >>> ArrayCollection;
>>> >>> Alert.show(MyModel. getInstance( ).SelectedBudget AC.getItemAt(
>>> >>> 0).payee) ;
>>> >>> var evt:CairngormEvent = new CairngormEvent( MyControl. EVENT_GET_
>>> >>> BUDGET_DETAILS) ;
>>> >>> CairngormEventDispa tcher.getInstanc e().dispatchEven t(evt);
>>> >>>
>>> >>> }
>>> >>>
>>> >>> public var Budget:BudgetVO;
>>> >>> public var BudgetAC:ArrayColle ction;
>>> >>> public var budgetID:Number;
>>> >>> public var SelectedBudgetAC: ArrayCollection;
>>> >>>
>>> >>> sorry about that..
>>> >>>
>>> >>> On Mon, Oct 6, 2008 at 9:02 PM, Tracy Spratt [EMAIL PROTECTED] com>
>>> >>> wrote:
>>> >>>> Then how are you expecting that setting "mySelectedRow" property will
>>> >>>> do
>>> >>>> anything regarding the "SelectedBudgetAC" property?
>>> >>>>
>>> >>>> Tracy
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>> ____________ _________ _________ __
>>> >>>>
>>> >>>> From: [EMAIL PROTECTED] ups.com [mailto:[EMAIL PROTECTED]
>>> >>>> ups.com] On
>>> >>>> Behalf Of Greg Morphis
>>> >>>> Sent: Monday, October 06, 2008 8:02 PM
>>> >>>> To: [EMAIL PROTECTED] ups.com
>>> >>>> Subject: Re: [flexcoders] handling data within a datagrid
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>> No, just global variables
>>> >>>>
>>> >>>> On Mon, Oct 6, 2008 at 7:13 PM, Tracy Spratt [EMAIL PROTECTED] com>
>>> >>>> wrote:
>>> >>>>> Does MyModel handle the relationship between mySelectedRow and
>>> >>>>> SelectedBudgetAC? Using setters or getters?
>>> >>>>>
>>> >>>>> Tracy
>>> >>>>>
>>> >>>>>
>>> >>>>>
>>> >>>>> ____________ _________ _________ __
>>> >>>>>
>>> >>>>> From: [EMAIL PROTECTED] ups.com [mailto:[EMAIL PROTECTED]
>>> >>>>> ups.com] On
>>> >>>>> Behalf Of Greg Morphis
>>> >>>>> Sent: Monday, October 06, 2008 7:48 PM
>>> >>>>> To: [EMAIL PROTECTED] ups.com
>>> >>>>> Subject: [flexcoders] handling data within a datagrid
>>> >>>>>
>>> >>>>>
>>> >>>>>
>>> >>>>> I've got my datagrid populating but I need to see that data in
>>> >>>>> aother
>>> >>>>> location within my app.
>>> >>>>> In my MyModel.as
>>> >>>>> I have a "global" variable
>>> >>>>> public var mySelectedRow: ArrayCollection;
>>> >>>>>
>>> >>>>> I've tried setting this variable in the dataGrid change event...
>>> >>>>> public function handleChangeEvent( event:Event) :void
>>> >>>>> {
>>> >>>>> MyModel.getInstance ().mySelectedRow = event.target. selectedItem as
>>> >>>>> ArrayCollection;
>>> >>>>> Alert.show(MyModel. getInstance( ).SelectedBudget AC.getItemAt(
>>> >>>>> 0).amount) ;
>>> >>>>> var evt:CairngormEvent = new
>>> >>>>> CairngormEvent( MyControl. EVENT_GET_ DATA_DETAILS) ;
>>> >>>>> CairngormEventDispa tcher.getInstanc e().dispatchEven t(evt);
>>> >>>>>
>>> >>>>> }
>>> >>>>>
>>> >>>>> The Alert returns a null error.. but it looks like it should be
>>> >>>>> working?
>>> >>>>> What I'm trying to do is I have a VO I need to populate.. I was
>>> >>>>> going
>>> >>>>> to do that within a command (is that best practice? -- to seperate
>>> >>>>> display from logic)
>>> >>>>> So anywho I'm trying to populate that arraycollection and then in
>>> >>>>> the
>>> >>>>> command do all the fun stuff...
>>> >>>>> var myVO:FootVO = MyModel.getInstance ().FooVO;
>>> >>>>> myVO.amount = MyModel.getInstance ().SelectedBudge tAC.getItemAt(
>>> >>>>> 0).amount;
>>> >>>>>
>>> >>>>> but I'm getting a null error.. is this the proper way to load a VO
>>> >>>>> from a selected DataGrid row?
>>> >>>>>
>>> >>>>> Thanks
>>> >>>>>
>>> >>>>>
>>> >>>>
>>> >>>>
>>> >>>
>>> >>> ________________________________
>>> >>> Add more friends to your messenger and enjoy! Invite them now.
>>> >>
>>> >
>>>
>>
>>
>