Focal Point
[SOLVED] need to update dataGrid in FLEX/ibiChartDataView

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9857097806

August 24, 2011, 03:18 PM
Gizmo
[SOLVED] need to update dataGrid in FLEX/ibiChartDataView
I need to somehow get the data grid in the ibiChartDataView to update. Two things need to happen, I need the amount column to update when I change the xField in my graph, and second, I need to be able to customize the column titles in the dataGrid as well so that they are user friendly names rather than field names.

Here is an example of what I'm doing. When you change the measurement field via the combobox, the graph updates, but the dataGrid in the chart data view does not (grab the corner of the graph to turn the page).

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600" xmlns:ibi="http://www.informationbuilders.com">
	<mx:Script>
		<![CDATA[
			import mx.events.ListEvent;
			private var myRequest:String = "TABLE FILE CAR SUM DEALER_COST RETAIL_COST SALES BY COUNTRY\nON TABLE PCHOLD FORMAT XML\nEND";
			[Bindable]
			protected var myUrl:String = "http://localhost/ibi_apps/WFServlet?IBIF_adhocfex=" + encodeURIComponent(myRequest);
			[Bindable]
			protected var fieldLabels:Array = new Array("Dealer Cost","Retail Cost","Sales");
			protected var fieldValues:Array = new Array("DEALER_COST","RETAIL_COST","SALES");
			
			protected function field_changeHandler(event:ListEvent):void
			{
				salesChart.series[0].xField = fieldValues[field.selectedIndex];
				salesChart.series[0].displayName = fieldLabels[field.selectedIndex];
			}
			
		]]>
	</mx:Script>
	
	<mx:SeriesInterpolate id="int" duration="800"/>
	
	<ibi:ibiCanvas x="10" y="10" width="1007" height="614">
		
		<mx:ComboBox id="field" x="283" y="10" dataProvider="{fieldLabels}" change="field_changeHandler(event)"></mx:ComboBox>
		<ibi:ibiDataGrid id="salesData" ibiUseColumns="COUNTRY,DEALER_COST,RETAIL_COST,SALES" seturl="{myUrl}" visible="false"/>
		
		<ibi:ibiChartDataView id="salesBook" height="300" width="400" activeGrabArea="corners" edgeAndCornerSize="20" y="57">
			<ibi:ibiChart>
				<ibi:ibiBarChart id="salesChart" x="61" y="79" width="300" height="400" ibiParent="salesData"
								 ibiXField="DEALER_COST" ibiYField="COUNTRY" showDataTips="true">
					<ibi:verticalAxis>
						<mx:CategoryAxis id="ps2axis" categoryField="COUNTRY"/>
					</ibi:verticalAxis>
					<ibi:series>
						<mx:BarSeries xField="DEALER_COST" displayName="Dealer Cost" showDataEffect="int">
							<mx:fill>
								<mx:LinearGradient angle="90">
									<mx:GradientEntry alpha="1" color="#8A0000" ratio="0" />
									<mx:GradientEntry alpha="1" color="#EA0000" ratio=".3" />
									<mx:GradientEntry alpha="1" color="#500000" ratio="1" />
								</mx:LinearGradient>
							</mx:fill>
						</mx:BarSeries>
					</ibi:series>		
				</ibi:ibiBarChart>
			</ibi:ibiChart></ibi:ibiChartDataView>
		
	</ibi:ibiCanvas>
	
</mx:Application>

This message has been edited. Last edited by: Gizmo,



Windows: WF 7.6.2: SQL Server 2008 R2
September 01, 2011, 04:31 PM
Gizmo
I've finally figured out the script to resolve the issue (field_changeHandler function). I'm not sure that this is the best way of doing this, but at least it works.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600" xmlns:ibi="http://www.informationbuilders.com">
	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.events.ListEvent;
			private var myRequest:String = "TABLE FILE CAR SUM DEALER_COST RETAIL_COST SALES BY COUNTRY\nON TABLE PCHOLD FORMAT XML\nEND";
			[Bindable]
			protected var myUrl:String = "http://localhost/ibi_apps/WFServlet?IBIF_adhocfex=" + encodeURIComponent(myRequest);
			[Bindable]
			protected var fieldLabels:Array = new Array("Dealer Cost","Retail Cost","Sales");
			protected var fieldValues:Array = new Array("DEALER_COST","RETAIL_COST","SALES");
			
			protected function field_changeHandler(event:ListEvent):void
			{
				salesChart.series[0].xField = fieldValues[field.selectedIndex];  // set chart data field name
				salesChart.series[0].displayName = fieldLabels[field.selectedIndex];  // set chart data label
				salesBook.content[1].columns[1].dataField = fieldValues[field.selectedIndex]; //set data grid field name
				salesBook.content[1].columns[1].headerText = fieldLabels[field.selectedIndex];  // set datagrid column title
			}
			
		]]>
	</mx:Script>
	
	<mx:SeriesInterpolate id="int" duration="800"/>
	
	<ibi:ibiCanvas id="dashboard" x="10" y="10" width="1007" height="614">
		
		<mx:ComboBox id="field" x="283" y="10" dataProvider="{fieldLabels}" change="field_changeHandler(event)"></mx:ComboBox>
		<ibi:ibiDataGrid id="salesData" ibiUseColumns="COUNTRY,DEALER_COST,RETAIL_COST,SALES" seturl="{myUrl}" visible="false"/>
		
		<ibi:ibiChartDataView id="salesBook" height="300" width="400" activeGrabArea="corners" edgeAndCornerSize="20" y="57">
			<ibi:ibiChart>
				<ibi:ibiBarChart id="salesChart" x="61" y="79" width="300" height="400" ibiParent="salesData"
								 ibiXField="DEALER_COST" ibiYField="COUNTRY" showDataTips="true">
					<ibi:verticalAxis>
						<mx:CategoryAxis id="ps2axis" categoryField="COUNTRY"/>
					</ibi:verticalAxis>
					<ibi:series>
						<mx:BarSeries xField="DEALER_COST" displayName="Dealer Cost" showDataEffect="int">
							<mx:fill>
								<mx:LinearGradient angle="90">
									<mx:GradientEntry alpha="1" color="#8A0000" ratio="0" />
									<mx:GradientEntry alpha="1" color="#EA0000" ratio=".3" />
									<mx:GradientEntry alpha="1" color="#500000" ratio="1" />
								</mx:LinearGradient>
							</mx:fill>
						</mx:BarSeries>
					</ibi:series>		
				</ibi:ibiBarChart>
			</ibi:ibiChart></ibi:ibiChartDataView>
		
	</ibi:ibiCanvas>
	
</mx:Application>





Windows: WF 7.6.2: SQL Server 2008 R2
September 01, 2011, 05:06 PM
<FreSte>
Gizmo,

Thanks for posting the solution. I have been trying to figure this out for hours, but withoput any luck.
Never thought you have to approach this via id=salesbook (I tried almost everything via id=saleschart).

So, thanks again

-Fred-