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.