PDA

View Full Version : datagrid item renderer


Anitha
04-11-2008, 08:30 AM
Hi all,

I have posted one blog yesterday named Troble with datagrid.
I tried the same problem in another way(using itemrenderer).But my badluck I cant meet the result in both two ways. Really iam confused ..Is it possible to call a dataservice while i click the cell content of a datgrid.

//My prb is
I have two datagrids.
The first datagrid is populated by a webservice result [fields : year,projected,achieved] .
The second datagrid is for when a year is selected from the first datagrid
the second datagrid is populated by another one service [fields :year,division,projected,achieved].Firstgrid works successfully.
Here I need to get the year value from first grid and pass it when
i invoke the data service method call to get the particular year status.My problem is when i run nothing happend[no error report also]

If someone could help me please, I would really appreciate .

Thanks in advance
Anitha

//here my code
import mx.events.ListEvent;
[Bindable]
public var selectedYear:Number;

[Bindable]
public var secondgridanswer:ArrayCollection=new ArrayCollection;


[Bindable]
public var answer:ArrayCollection=new ArrayCollection;


private function remotingHandler(event:ResultEvent):void
{
answer=(event.result.Tables["annualresult"].Rows);
var ans:Array=ArrayUtil.toArray(answer);
}



private function datachangeHandler(evt:ListEvent):void
{
var selectedYear:Number=evt.itemRenderer.data.year;
myservice.getDivision.send(selectedYear);

}
private function onResult(event:ResultEvent):void
{
secondgridanswer=(event.result.Tables["divisionshow"].Rows);
var ans1:Array=ArrayUtil.toArray(secondgridanswer);
}

]]>



</mx:Script>




<mx:WebService id="myservice" wsdl="http://localhost/Service.asmx?wsdl"
showBusyCursor="true" fault="mx.controls.Alert.show
(event.fault.faultString);">
<mx:operation name="getSelectionPeriod" resultFormat="object"
fault="mx.controls.Alert.show(event.fault.faultString);"
result="remotingHandler(event)">
<mx:request xmlns="">
<Fromyear>{fy.selectedDate.getFullYear()}</Fromyear>
<Toyear>{ty.selectedDate.getFullYear()}</Toyear>
</mx:request>
</mx:operation>
<mx:operation name="getDivision" resultFormat="object" result="onResult
(event)">
<mx:request xmlns="">
<year>{selectedYear}</year>
</mx:request>
</mx:operation>
</mx:WebService>

<mx:DataGrid id="firstgrid" x="60" y="132" dataProvider="{answer}"
change="datachangeHandler(event)">
<mx:columns>
<mx:DataGridColumn headerText="year" dataField="year"/>
<mx:DataGridColumn headerText="projected" dataField="projected"/>
<mx:DataGridColumn headerText="achieved" dataField="achieved"/>
</mx:columns>
</mx:DataGrid>


<mx:DataGrid id="secondgrid" x="314" y="337" dataProvider="{secondgridanswer}">
<mx:columns>

<mx:DataGridColumn headerText="year" dataField="year"/>
<mx:DataGridColumn headerText="division" dataField="division"/>
<mx:DataGridColumn headerText="projected" dataField="projected"/>
<mx:DataGridColumn headerText="achieved" dataField="achieved"/>

</mx:columns>
</mx:DataGrid>

kahuja
04-11-2008, 09:04 AM
1. Why different threads?

2. Refer to the other one and I think you would have a solution