![]()
![]()
My Requirement is Approvals Column should show Status of approval in the summary field against rs:285644 on 1st row as Not Validated and not in the below rows, How to achieve this...?
My Sample Data which I am parsing to display the above UI is an XML as follows,
<regions>
<ApprovalStatus_RegionNorth>NotValidated</ApprovalStatus_RegionNorth>
<UserType>HQ</UserType>
<region>
<DISPLAY_NAME>REGION_NORTH</DISPLAY_NAME>
<iUserGroup>5816</iUserGroup>
<sDescription>BPCL Corp Ltd-BPCL-BPC1515</sDescription>
<uptimePercentage>100.0</uptimePercentage>
<totalVehicles>2</totalVehicles>
<reportingVehicles>1</reportingVehicles>
<billingAmount>928</billingAmount>
<sapCode>BPC1515</sapCode>
</region>
</regions>
Please let me know if you need any more data to solve the issue.
My Full mxml code as follows,
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="application1_creationCompleteHandler(event)" viewSourceURL="srcview/index.html">
<fx:Declarations>
<mx:DateFormatter id="dateFormatter" formatString="DD-MMM-YYYY" />
<mx:HTTPService
id="ewsCumulativeDetails"
url="http://localhost:8080/cms/xml/populateBillingByHierarchy.action"
resultFormat="text" method="POST"
result="ewsCumulativeDetails_resultHandler(event)" fault="ewsCumulativeDetails_faultHandler(event)">
</mx:HTTPService>
<mx:HTTPService
id="billingApproval"
url="http://localhost:8080/cms/xml/billingApproval.action"
resultFormat="text" method="POST"
result="ewsCumulativeDetails_resultHandler(event)" fault="ewsCumulativeDetails_faultHandler(event)">
</mx:HTTPService>
<mx:HTTPService
id="billingRejection"
url="http://localhost:8080/cms/xml/billingRejection.action"
resultFormat="text" method="POST"
result="ewsCumulativeDetails_resultHandler(event)" fault="ewsCumulativeDetails_faultHandler(event)">
</mx:HTTPService>
</fx:Declarations>
<fx:Script>
<![CDATA[
import PopUp.Window;
import com.adobe.serialization.json.JSON;
import com.rupendra.utils.ADGExcelTripReport;
import com.rupendra.utils.BillingByHierarchyExcel;
import components.HeaderRendererDistance;
import components.HeaderRendererTT;
import components.MyTitleWindow;
import controls.CursorFactory;
import controls.CursorFactorySWF;
import controls.DropDownSelector;
import events.DropDownEvent;
import flash.net.navigateToURL;
import mx.binding.utils.BindingUtils;
import mx.collections.ArrayCollection;
import mx.collections.Sort;
import mx.collections.SortField;
import mx.collections.XMLListCollection;
import mx.controls.Alert;
import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
import mx.controls.advancedDataGridClasses.AdvancedDataGridColumnGroup;
import mx.core.FlexGlobals;
import mx.effects.effectClasses.HideShowEffectTargetFilter;
import mx.events.FlexEvent;
import mx.managers.CursorManager;
import mx.managers.PopUpManager;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.xml.SimpleXMLDecoder;
import mx.rpc.xml.SimpleXMLEncoder;
import mx.utils.ArrayUtil;
import mx.utils.ObjectUtil;
import mx.collections.IViewCursor;
[Bindable]
private var result:XML;
[Bindable]
public var resultData:XMLList;
[Bindable]
public var userGroup:String;
[Bindable]
public var userName:String;
[Bindable]
public var displayName:String;
[Bindable]
private var midDate:Date;
[Bindable]
public var userId:String;
[Bindable]
private var dpTrip:ArrayCollection;
[Bindable]
public var jsonTrip:Object;
public var daysOfMonth:int;
public var fd:Date=new Date();
public var ld:Date=new Date();
[Bindable]
public var months:ArrayCollection = new ArrayCollection([
{ Id:""},
{ Id:"Jan", month:"00" , lastDay:"31"},
{ Id:"Feb", month:"01" , lastDay:"28"},
{ Id:"Mar", month:"02" , lastDay:"31"},
{ Id:"Apr", month:"03" , lastDay:"30"},
{ Id:"May", month:"04" , lastDay:"31"},
{ Id:"June", month:"05" , lastDay:"30"},
{ Id:"July", month:"06" , lastDay:"31"},
{ Id:"Aug", month:"07" , lastDay:"31"},
{ Id:"Sep", month:"08" , lastDay:"30"},
{ Id:"Oct", month:"09" , lastDay:"31"},
{ Id:"Nov", month:"10" , lastDay:"30"},
{ Id:"Dec", month:"11" , lastDay:"31"} ]);
protected function ewsCumulativeDetails_resultHandler(event:ResultEvent):void
{
Alert.show("dataFieldDataFetched");
var resultString:String = event.result.toString();
// result = new XML("<regions><ApprovalStatus_RegionNorth>NotValidated</ApprovalStatus_RegionNorth><UserT ype>HQ</UserType><region><ApprovalStatus>Not Validated</ApprovalStatus><DISPLAY_NAME>REGION_NORTH</DISPLAY_NAME><iUserGroup>5816</iUse rGroup><sDescription>BPCL Corp Ltd-BPCL-BPC1515</sDescription><uptimePercentage>100.0</uptimePercentage><totalVehicles>2 </totalVehicles><reportingVehicles>1</reportingVehicles><billingAmount>928</billingAmount> <sapCode>BPC1515</sapCode></region></regions>");
result = new XML(resultString);
resultData = result.region;
gc2.refresh();
adg2.dataProvider = gc2;
if(result.UserType == "HQ"){
adg2.visible = true;
// Approvals.visible = true;
// ApprovalsHeader.visible = true;
// regNorth.text = result.ApprovalStatus_RegionNorth;
// regSouth.text = result.ApprovalStatus_RegionSouth;
// regEast.text = result.ApprovalStatus_RegionEast;
// regWest.text = result.ApprovalStatus_RegionWest;
}
else{
adg2.visible = true;
if(result.UserType == "REGION_NORTH(CM)")
{
if(result.ApprovalStatus_RegionNorth == "Not Validated")
{
Approve.visible="true";
CallBack.visible="true";
}
}
if(result.UserType == "REGION_SOUTH(CM)")
{
if(result.ApprovalStatus_RegionSouth == "Not Validated")
{
Approve.visible="true";
CallBack.visible="true";
}
}
if(result.UserType == "REGION_EAST(CM)")
{
if(result.ApprovalStatus_RegionEast== "Not Validated")
{
Approve.visible="true";
CallBack.visible="true";
}
}
if(result.UserType == "REGION_WEST(CM)")
{
if(result.ApprovalStatus_RegionWest == "Not Validated")
{
Approve.visible="true";
CallBack.visible="true";
}
}
}
}
protected function ewsCumulativeDetails_faultHandler(event:FaultEvent):void
{
Alert.show("fault");
// TODO Auto-generated method stub
}
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
var params:Object = new Object();
var xmlD:XML = new XML(this.parameters.paramVal);
params.uId = this.parameters.uId;
userId = this.parameters.uId;
// ewsCumulativeDetails.send(params);
}
public function openDetailedForUser():void{
var win : Window = new Window();
PopUpManager.addPopUp(win,this,true);
PopUpManager.centerPopUp(win);
}
private function labelFunction1(item:Date):String {
midDate = item;
return dateFormatter.format(item);
}
private function labelFunction2(item:Date):String {
return dateFormatter.format(item);
}
// private function disableinvalidDates(toBeDisabled:String):void{
// switch(toBeDisabled)
// {
// //disabledRanges="{[{rangeEnd: new Date((new Date()).getTime() - (1000*60*60*24))}]}" selectableRange="{{rangeStart : new Date()}}"
// case "FromDate":
// fDate.selectableRange = {rangeStart:new Date((new Date()).getTime() - (1000*60*60*1440)),rangeEnd: new Date()};
// break;
// case "ToDate":
//
//
// tDate.selectableRange = {rangeStart: fDate.value < new Date((1000*60*60*720)) ? new Date() : fDate + (1000*60*60*720), rangeEnd: new Date()};
// break;
// }
// }
// protected function tDate_clickHandler(clickedField:String):void
// {
// var addDate:Date = new Date(midDate.fullYear,
// midDate.month,
// midDate.date+30,
// midDate.hours,
// midDate.minutes,
// midDate.seconds,
// midDate.milliseconds);
//
// if(addDate > new Date())
// addDate = new Date();
//
// switch(clickedField)
// {
// case "ToDate":
// fDate.text.length > 0 ? tDate.selectableRange = {rangeStart: midDate,rangeEnd: addDate} : Alert.show("You need to Select from Date first");
// break;
// }
// }
//
protected function button3_clickHandler(event:MouseEvent):void
{
Alert.show("dataFieldSubmit");
adg2.visible = false;
// ApprovalsHeader.visible = false;
// Approvals.visible = false;
resultData = null;
gc2.refresh();
adg2.dataProvider = null;
Approve.setVisible(false);
CallBack.setVisible(false);
var params:Object = new Object();
params.monthAndYear = pickYear.selectedItem+''+pickMonth.selectedItem.month;
fd.setFullYear(pickYear.selectedItem,pickMonth.selectedItem.month,1);
var xmlD:XML = new XML(this.parameters.paramVal);
ld=new Date(pickYear.selectedItem, pickMonth.selectedItem.month, pickMonth.selectedItem.lastDay);
params.uId = this.parameters.uId;
params.fromDate = labelFunction1(fd) ;
params.toDate = labelFunction1(ld);
ewsCumulativeDetails.send(params);
}
public function approval_clickHandler(event:MouseEvent):void
{
var params:Object = new Object();
params.monthAndYear = pickYear.selectedItem+''+pickMonth.selectedItem.month;
var fd:Date=new Date();
fd.setFullYear(pickYear.selectedItem,pickMonth.selectedItem.month,1);
var xmlD:XML = new XML(this.parameters.paramVal);
var ld:Date=new Date(pickYear.selectedItem, pickMonth.selectedItem.month, pickMonth.selectedItem.lastDay);
params.uId = this.parameters.uId;
params.fromDate = labelFunction1(fd) ;
params.toDate = labelFunction1(ld);
billingApproval.send(params);
}
public function rejection_clickHandler(event:MouseEvent):void
{
var params:Object = new Object();
params.monthAndYear = pickYear.selectedItem+''+pickMonth.selectedItem.month;
var fd:Date=new Date();
fd.setFullYear(pickYear.selectedItem,pickMonth.selectedItem.month,1);
var xmlD:XML = new XML(this.parameters.paramVal);
var ld:Date=new Date(pickYear.selectedItem, pickMonth.selectedItem.month, pickMonth.selectedItem.lastDay);
params.uId = this.parameters.uId;
params.fromDate = labelFunction1(fd) ;
params.toDate = labelFunction1(ld);
billingRejection.send(params);
}
public function nciLabelFunction(item:Object, column:AdvancedDataGridColumn):int
{
var param:int = item.totalVehicles-item.reportingVehicles;
return param;
}
public function mySummaryFunction(iterator:IViewCursor, dataField:String, operation:String):Object {
var param:String;
Alert.show("dataField");
if(dataField == "REGION_EAST")
{
param = result.ApprovalStatus_RegionEast;
}
if(dataField == "REGION_NORTH")
{
param = result.ApprovalStatus_RegionNorth;
}
if(dataField == "REGION_WEST")
{
param = result.ApprovalStatus_RegionWest;
}
if(dataField == "REGION_SOUTH")
{
param = result.ApprovalStatus_RegionSouth;
}
return param;
}
public function approvalFunction(item:Object, column:AdvancedDataGridColumn):Object {
var param:String;
if(item.DISPLAY_NAME == "REGION_EAST")
{
param = result.ApprovalStatus_RegionEast;
}
if(item.DISPLAY_NAME == "REGION_NORTH")
{
param = result.ApprovalStatus_RegionNorth;
}
if(item.DISPLAY_NAME == "REGION_WEST")
{
param = result.ApprovalStatus_RegionWest;
}
if(item.DISPLAY_NAME == "REGION_SOUTH")
{
param = result.ApprovalStatus_RegionSouth;
}
return param;
}
]]>
</fx:Script>
<mx:VBox width="100%" height="100%" verticalScrollPolicy="auto" horizontalScrollPolicy="off">
<mx:ApplicationControlBar id="dockedBar">
<mx:HBox id="dateSelect" width="100%" horizontalAlign="center">
<mx:HBox width="100%" height="100%">
<s:Label text="Month" height="100%" verticalAlign="middle"/>
<mx:ComboBox id="pickMonth" dataProvider="{months}" labelField="Id" height="100%"/>
</mx:HBox>
<mx:HBox width="100%" height="100%" >
<s:Label text="Year" height="100%" verticalAlign="middle" />
<mx:ComboBox id="pickYear" height="100%">
<mx:dataProvider>
<fx:String></fx:String>
<fx:String>2013</fx:String>
<fx:String>2014</fx:String>
<fx:String>2015</fx:String>
<fx:String>2016</fx:String>
<fx:String>2017</fx:String>
</mx:dataProvider>
</mx:ComboBox>
</mx:HBox>
<mx:Button label="Submit" click="button3_clickHandler(event)"/>
<mx:Button id="Approve" visible="false" label="Approve" click="approval_clickHandler(event);" />
<mx:Button id="CallBack" visible="false" label="Reject" click="rejection_clickHandler(event);" />
</mx:HBox>
</mx:ApplicationControlBar>
<!-- <mx:ApplicationControlBar width="100%">
<mx:Box direction="vertical" horizontalAlign="center">
<mx:VBox>
<mx:HBox visible = "false" id="ApprovalsHeader" >
<s:Label fontSize="16" fontWeight="bold" text="Region Wise Approval Details " height="100%" verticalAlign="middle"/>
</mx:HBox>
</mx:VBox>
<mx:VBox>
<mx:HBox visible = "false" id="Approvals" >
<s:Label text="Region North : " height="100%" verticalAlign="middle"/>
<s:Label id = "regNorth"/>
<s:Label text=", Region South : " height="100%" verticalAlign="middle"/>
<s:Label id = "regSouth"/>
<s:Label text=", Region East : " height="100%" verticalAlign="middle"/>
<s:Label id = "regEast"/>
<s:Label text=", Region West : " height="100%" verticalAlign="middle"/>
<s:Label id = "regWest"/>
</mx:HBox>
</mx:VBox>
</mx:Box>
</mx:ApplicationControlBar>
-->
<mx:Box>
<mx:VBox>
<mx:HBox width="1545" height="177">
<mx:AdvancedDataGrid creationComplete="gc2.refresh();adg2.dataProvider = gc2;" width="100%" height="100%" id = "adg2" visible = "false"
disclosureClosedIcon="@Embed(source='assets/icons/application_side_expand.png')"
disclosureOpenIcon="@Embed(source='assets/icons/application_put.png')"
folderOpenIcon="@Embed(source='assets/icons/group_link.png')"
folderClosedIcon="@Embed(source='assets/icons/group_link.png')"
defaultLeafIcon="@Embed(source='assets/icons/arrow_right.png')"
>
<mx:dataProvider>
<mx:GroupingCollection2 source="{resultData}" id="gc2" childrenField="undefined" >
<mx:Grouping>
<mx:GroupingField name="DISPLAY_NAME">
<mx:summaries>
<mx:SummaryRow summaryPlacement="group">
<mx:fields>
<mx:SummaryField2 label="Total Transporters" dataField="sDescription" summaryOperation="COUNT"/>
<mx:SummaryField2 dataField="totalVehicles" summaryOperation="SUM"/>
<mx:SummaryField2 dataField="reportingVehicles" summaryOperation="SUM"/>
<mx:SummaryField2 dataField="nci" summaryOperation="SUM"/>
<mx:SummaryField2 dataField="uptimePercentage" summaryOperation="AVG"/>
<mx:SummaryField2 dataField="billingAmount" summaryOperation="SUM"/>
<mx:SummaryField2 dataField="billingAmount" summaryOperation="SUM"/>
<!-- <mx:SummaryField label="Approvals" dataField="DISPLAY_NAME" summaryFunction="mySummaryFunction"/> -->
</mx:fields>
</mx:SummaryRow>
</mx:summaries>
</mx:GroupingField>
</mx:Grouping>
</mx:GroupingCollection2>
<!-- <mx:AdvancedDataGridColumn headerText="Approvals"
editorDataField="status"
labelFunction="approvalLabelFunction"/> -->
</mx:dataProvider>
<mx:groupedColumns>
<mx:AdvancedDataGridColumn dataField="sDescription"
headerText="Transporter Name">
<mx:itemRenderer>
<fx:Component>
<mx:LinkButton label="{new XML(this.data).sDescription}"
click="linkbutton2_clickHandler(event)"
textAlign="left">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
protected function linkbutton2_clickHandler(event:MouseEvent):void
{
trace(new XML(this.data).sDescription);
outerDocument.userName = new XML(this.data).sDescription;
outerDocument.userGroup = new XML(this.data).iUserGroup;
outerDocument.displayName = new XML(this.data).DISPLAY_NAME;
outerDocument.openDetailedForUser();
}
]]>
</fx:Script>
</mx:LinkButton>
</fx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
<mx:AdvancedDataGridColumn dataField="Total Transporters"
headerText="Total Transporters"/>
<mx:AdvancedDataGridColumn dataField="totalVehicles"
headerText="Total Vehicles"/>
<mx:AdvancedDataGridColumn dataField="reportingVehicles"
headerText="Reporting Vehicles"/>
<mx:AdvancedDataGridColumn editorDataField="nci"
labelFunction="nciLabelFunction"
headerText="Needing Customer Input"/>
<mx:AdvancedDataGridColumn dataField="uptimePercentage"
headerText="Uptime Percentage"/>
<mx:AdvancedDataGridColumn dataField="billingAmount"
headerText="Billing Amount"/>
<mx:AdvancedDataGridColumn dataField="billingAmount" headerText="Approvals"/>
<!-- <mx:AdvancedDataGridColumn visible="false" dataField = "ApprovalStatus" headerText="DummyApprovals"/> -->
</mx:groupedColumns>
</mx:AdvancedDataGrid>
<mx:AdvancedDataGrid id = "Approvals">
<mx:groupedColumns>
<mx:AdvancedDataGridColumn headerText="Approvals">
</mx:AdvancedDataGridColumn>
</mx:groupedColumns>
</mx:AdvancedDataGrid>
</mx:HBox>
</mx:VBox>
</mx:Box>
</mx:VBox>
<mx:HBox horizontalAlign="right" width="100%" paddingRight="15">
<mx:Image id="exportButton"
source="@Embed('assets/icons/Excel-16.gif')"
useHandCursor="true"
buttonMode="true"
click="BillingByHierarchyExcel.exportToExcel(adg2,'BillingCumulativedata.xls')"
visible="true"/>
</mx:HBox>
</s:Application>