- 浏览: 51362 次
- 性别:
- 来自: 济南
文章分类
最新评论
弹出窗口类:CusterEdit.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" width="400" height="300"
creationComplete="initComponent()"
showCloseButton="true"
close="closeWindow()">
<mx:Script>
<![CDATA[
/* 数据xml格式如下:
<items>
<item label="Tom" data="num001"/>
<item label="Lucy" data="num002"/>
</items>
*/
import mx.managers.PopUpManager;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
[Bindable]public var mainApp:Object = null;
[Bindable]public var headTitle:String;
[Bindable]public var url:String;
[Bindable]public var selectedItem:Object;
[Bindable]public var callbackFunction:Function; //回调函数
[Bindable]public var customer_codeS:String;//客户编码
[Bindable]public var customer_nameS:String;//客户名称
[Bindable]public var coordinatexS:String;//x坐标
[Bindable]public var coordinateyS:String;//y坐标
[Bindable]public var lineArr:ArrayCollection;//线路计划
[Bindable]public var ship_periodS:String;//配送周期
[Bindable]
public var cards:ArrayCollection = new ArrayCollection(
[ {label:"Visa",data:1}, //这样的数组分配方式也是第一次见:) 经过分析才学习到:这里的"data"似乎是自定义的变量名,label是组件"label"
{label:"MasterCard", data:2},
{label:"American Express", data:3} ]);
private function initComponent():void {
//listDataService.url = url;
listDataService.send();
}
//closeWindow
private function closeWindow():void {
PopUpManager.removePopUp(this);
}
private function submit():void {
PopUpManager.removePopUp(this);
if (coordinatex.text != null && coordinatey.text != null) {
//调用父窗体的方法并以参数形式返回选择结果
callbackFunction.call(mainApp, coordinatex.text,coordinatey.text,ship_period.text,line.selectedItem["data"],line.selectedItem["label"]);
} else{
Alert.show("怎么走了这");
}
}
private function mySelection(oEvent:Event):void {
selectedItem = oEvent.target.selectedItem;
}
private function initListData(event:ResultEvent):void {
//使用HTTPService返回的xml数据,初始化List数据
//dataList.dataProvider = event.result.items.item;
}
]]>
</mx:Script>
<mx:HTTPService id="listDataService" url="{url}" showBusyCursor="true" result="initListData(event)" />
<mx:Label text="{headTitle}"/>
<mx:FormItem label="客户编码:" width="237">
<mx:Text id="customer_code" width="124" height="31"/>
</mx:FormItem>
<mx:FormItem label="客户名称:" width="237">
<mx:Text id="customer_name" width="124"/>
</mx:FormItem>
<mx:FormItem label="经度坐标:" width="237">
<mx:TextInput id="coordinatex" width="124"/>
</mx:FormItem>
<mx:FormItem label="纬度坐标:" width="237">
<mx:TextInput id="coordinatey" width="124"/>
</mx:FormItem>
<mx:FormItem label="配送周期:" width="237">
<mx:TextInput id="ship_period" width="145"/>
</mx:FormItem>
<mx:FormItem label="线 路:" width="237">
<mx:ComboBox id="line" width="147"/>
</mx:FormItem>
<mx:VBox width="100%">
<mx:Button label="保存" click="submit();"/>
</mx:VBox>
</mx:TitleWindow>
父窗体:CustomerList.mxml里面用的是DataGrid 修改、地图定位
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
width="990"
height="304"
showCloseButton="true"
creationComplete="init()"
close="{PopUpManager.removePopUp(this)}"
title="零售户信息"
fontSize="12"
xmlns:components="com.bluesword.cargps.components.*">
<mx:Script source="utils.as"/>
<mx:Script>
<![CDATA[
import com.bluesword.cargps.socket.CustomerMap;
import com.bluesword.cargps.utils.Global;
import mx.controls.Alert;
import mx.controls.dataGridClasses.DataGridColumn;
import com.bluesword.cargps.socket.ChengWeiData;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.remoting.RemoteObject;
import mx.managers.PopUpManager;
import mx.events.ListEvent;
import mx.rpc.events.ResultEvent;
import mx.events.DataGridEvent;
import com.esri.ags.Map;
import com.bluesword.cargps.AcceptUserInfo
import mx.collections.ArrayCollection;
import mx.rpc.events.FaultEvent;
import com.bluesword.cargps.frame.report.CusterEdit;
import mx.containers.TitleWindow;
import mx.managers.PopUpManager;
private static var flexSession:RemoteObject = null;
private var customerService:RemoteObject;
public var userInfo:Object;
[Bindable]
private var array_qy:ArrayCollection;
[Bindable]
private var array_start:ArrayCollection;
[Bindable]
private var array_info:ArrayCollection;
[Bindable] public var array_line:ArrayCollection;
[Bindable]
public var map:Map;
public var acceptUserInfo:AcceptUserInfo;
public var checkBox_info:String = new String();
private function init():void
{
customerService = new RemoteObject();
customerService.destination = "story.customerService";
flexSession = new RemoteObject();
flexSession.addEventListener(FaultEvent.FAULT,faultHandler);
flexSession.destination="flexSession";
//根据所选情况进行查询
customerService.getCustomerInfo.addEventListener(ResultEvent.RESULT, getCarMonthOilUseInfoHandler);
customerService.getCustomerType.addEventListener(ResultEvent.RESULT,addCustType);
customerService.getCustomerType("CUSTOMER_STATUS");
customerService.onSubmit.addEventListener(ResultEvent.RESULT,getSubmit);
//初始化客户类型
addCustStart();
flexSession.getLoginUser.addEventListener(ResultEvent.RESULT,getFlexSession);//获得角色
flexSession.getLoginUser();
//获得线路
customerService.getLine.addEventListener(ResultEvent.RESULT,getLine);
customerService.getLine();
}
//获得线路
public function getLine(event:ResultEvent):void{
array_line = event.result as ArrayCollection;
}
//获得权限
public function getFlexSession(event:ResultEvent):void{
var tmp:Object = event.result;
userInfo = String(tmp.role_id);
}
//绑定客户类型
private function addCustType(event:ResultEvent):void
{
array_qy = event.result as ArrayCollection;
var def:Object = {
type_code: "0",
type_name: "全部"
};
array_qy.addItemAt(def, 0);
custType.selectedIndex = 0;
}
//绑定状态
private function addCustStart():void
{
array_start = new ArrayCollection;
var str1:Object = {start_code:"1",start_name:"提交"};
array_start.addItemAt(str1,0);
var str2:Object = {start_code:"2",start_name:"未提交"};
array_start.addItemAt(str2,1);
startM.selectedIndex = 0;
}
/**
* 获取车辆日里程油耗统计信息
*/
private function getCarMonthOilUseInfoHandler(event:ResultEvent):void
{
array_info = event.result as ArrayCollection;
// gc.refresh();
var item:Object = (myDG.dataProvider as ArrayCollection).getItemAt(1);
if (array_info.length > 0)
Alert.show("查询完毕");
else
Alert.show("查询完毕,无信息");
}
/**
* 根据指定的条件查询
*/
private function onQuery():void
{
customerService.getCustomerInfo(customer_code.text,customer_name.text,startTime.text,endTime.text,custType.selectedItem.type_code,startM.selectedItem.start_code);
}
/**
* 导出为Excel文件
*/
private function onCreate():void
{
loadDGInExcel(myDG, Global.EXCEL_JSP, "零售户信息表");
}
/**
* 双击车辆树型列表, 居中定位该车
*/
public function onDoubleClick(event:ListEvent):void
{
var datagrid:DataGrid = event.target as DataGrid;
var cols:DataGridColumn = myDG.columns[event.columnIndex];
var customer_no = datagrid.selectedItem["customer_no"];
var customer:CustomerMap = new CustomerMap(map);
customer.showCustomerOnMap(customer_no);
}
//保存
private function update(e:ListEvent)
{
/*var colIndex:Number = e.columnIndex;
var datagrid:DataGrid = e.target as DataGrid;
var col:DataGridColumn = datagrid.columns[colIndex];
var x:Number = datagrid.selectedItem["coordinatex"];
var y:Number = datagrid.selectedItem["coordinatey"];*/
//acceptUserInfo
myDG.invalidateList();
}
public function onEditEnd(event:DataGridEvent):void
{
/*if(event.reason == DataGridEventReason.NEW_ROW || event.reason == DataGridEventReason.OTHER){
acItemsSelected = dg.selectedItem;
var code:String = acItemsSelected.customer_code;
var x:Number = acItemsSelected.coordinatex;
var y:Number = acItemsSelected.coordinatey;
customerService.update(code,x,y);
}*/
if(event.dataField=="coordinatex"){
var datagrid:DataGrid = event.target as DataGrid;
var cols:DataGridColumn = myDG.columns[event.columnIndex];
//编辑后新的值
var x:Number = myDG.itemEditorInstance[cols.editorDataField];
var code:String = datagrid.selectedItem["customer_code"];
var y:Number = datagrid.selectedItem["coordinatey"];
customerService.update(code,x,y);
}
if(event.dataField == "coordinatey"){
var datagrid:DataGrid = event.target as DataGrid;
var cols:DataGridColumn = myDG.columns[event.columnIndex];
var y:Number = myDG.itemEditorInstance[cols.editorDataField];
var code:String = datagrid.selectedItem["customer_code"];
var x:Number = datagrid.selectedItem["coordinatex"];
customerService.update(code,x,y);
}
}
//修改方法
public function onEdit():void
{
var x:Number = myDG.selectedItem["coordinatex"];
var code:String = myDG.selectedItem["customer_code"];
var name:String = myDG.selectedItem["customer_name"];
var y:Number = myDG.selectedItem["coordinatey"];
var ship_period = myDG.selectedItem["ship_period"];
//customerService.update(code,x,y);
var titleWindowInstance:CusterEdit = CusterEdit(PopUpManager.createPopUp(this, CusterEdit, false));
titleWindowInstance.title = "零售户资料修改";
titleWindowInstance.width = 400;
titleWindowInstance.height = 300;
titleWindowInstance.mainApp = this;
titleWindowInstance.customer_code.text = code;//客户code
titleWindowInstance.customer_name.text = name;//客户名称
titleWindowInstance.coordinatex.text = x.toString();//x坐标
titleWindowInstance.coordinatey.text = y.toString();//y坐标
titleWindowInstance.ship_period.text = ship_period;//配送周期
titleWindowInstance.line.dataProvider = array_line;//线路
titleWindowInstance.url="http://localhost:9090/index.mxml";
titleWindowInstance.callbackFunction = this.myFunction;
PopUpManager.centerPopUp(titleWindowInstance);
}
public function myFunction(x:String,y:String,ship_periodS:String,lineCode:String,lineName:String):void {
Alert.show("x:"+x+"y:"+y+"配送周期"+ship_periodS+lineCode+lineName);
//array_info.getItemAt(myDG.selectedIndex).coordinatex = x;
//array_info.setItemAt(x,);
var customer_code:String = myDG.selectedItem["customer_code"];//客户编号
var customer_name:String = myDG.selectedItem["customer_name"];//客户名称
var manager_code:String = myDG.selectedItem["manager_code"];//客户经理CODE
var manager_name:String = myDG.selectedItem["manager_name"];//客户经理名称
var customer_no:String = myDG.selectedItem["customer_no"];//专卖证号
var customer_status:String = myDG.selectedItem["customer_status"];//客户类型
var customer_status_code:String = myDG.selectedItem["customer_status_code"];//客户类型编码
var customer_type_name:String = myDG.selectedItem["customer_type_name"];//状态
var customer_start_type:String = myDG.selectedItem["customer_start_type"];//状态编码
var temp:Object = {customer_code:customer_code,
customer_name:customer_name,
manager_code:manager_code,
manager_name:manager_name,
coordinatex:x,
coordinatey:y,
ship_period:ship_periodS,
ship_line_id:lineCode,
ship_line_name:lineName,
customer_no:customer_no,
customer_status:customer_status,
customer_status_code:customer_status_code,
customer_type_name:customer_type_name,
customer_start_type:customer_start_type
};
array_info.setItemAt(temp,myDG.selectedIndex);//修改
}
//定位方法
public function onLocation():void
{
var customer_no = myDG.selectedItem["customer_no"];
var customer:CustomerMap = new CustomerMap(map);
customer.showCustomerOnMap(customer_no);
}
//查询后台错误处理
public function faultHandler(evt:FaultEvent):void{
trace(evt.fault.message);
}
//提交
public function onSubmit():void
{
if(checkBox_info!="" && checkBox_info.split(";").length>0){
customerService.onSubmit(checkBox_info);
}else{
Alert.show("请选择要提交的客户!");
}
}
public function getSubmit(event:ResultEvent):void
{
var outs:String = String(event.result);
if(outs=="提交成功") onQuery();
Alert.show(outs);
}
public function clickHanlder(obj:Object):void{
if(obj.chxBox.selected){
checkBox_info += array_info.getItemAt(myDG.selectedIndex).customer_code+";";
Alert.show(checkBox_info);
}else{
var code:String = array_info.getItemAt(myDG.selectedIndex).customer_code;
var newArr:String = new String();
if(checkBox_info!=null && checkBox_info.length>0){
var arr:Array = checkBox_info.split(";");
for(var i:Number=0;i<arr.length;i++){
var s:String = String(arr[i]);
if(s!=code){
newArr += s+";";
}
}
}
checkBox_info = newArr ;
}
}
]]>
</mx:Script>
<mx:Canvas width="100%"
height="100%">
<mx:FormItem x="231.5"
y="10"
label="客户编号:"
width="71">
</mx:FormItem>
<mx:FormItem x="6"
y="10"
label="客户名称:">
</mx:FormItem>
<mx:TextArea id="customer_code" x="310.5" y="11" width="94.5" leading="10" height="22">
</mx:TextArea>
<mx:FormItem x="7"
y="43"
label="新增用户日期:"
width="183"
horizontalAlign="left">
<components:CusDateField id="startTime"
width="104"
height="24"
defFormatString="YYYY-MM-DD"/>
</mx:FormItem>
<mx:FormItem x="191"
y="43"
label="-"
width="174"
horizontalAlign="left">
<components:CusDateField id="endTime"
width="104"
height="24"
defFormatString="YYYY-MM-DD"/>
</mx:FormItem>
<mx:FormItem label="客户类型:" y="41" x="367">
<mx:ComboBox id="custType"
width="89"
labelField="type_name"
dataProvider="{array_qy}">
</mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="状态" y="41" x="534" width="114">
<mx:ComboBox id="startM"
labelField="start_name"
dataProvider="{array_start}" width="68">
</mx:ComboBox>
</mx:FormItem>
<mx:Button x="413"
y="9"
label="查询"
click="onQuery()"
width="69"/>
<mx:Button x="509"
y="9"
label="提交"
click="onSubmit()"
width="69"/>
<mx:TabNavigator x="0"
y="76"
width="100%"
height="80%">
<mx:Canvas label="零售户信息"
id="carsta"
width="100%"
height="100%"
horizontalScrollPolicy="off"
verticalScrollPolicy="off">
<mx:DataGrid id="myDG"
x="0"
y="0"
width="{carsta.width}"
height="{carsta.height}"
dataProvider="{array_info}" editable="true"
>
<mx:columns>
<mx:DataGridColumn headerText="选择" editable="false">
<mx:itemRenderer>
<mx:Component>
<mx:HBox>
<mx:CheckBox id="chxBox" label="{data.name}" name="custCheck" click="outerDocument.clickHanlder(this)"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="customer_code" headerText="客户编号" editable="false"/>
<mx:DataGridColumn dataField="customer_name" headerText="客户名称" editable="false"/>
<mx:DataGridColumn dataField="manager_code" headerText="客户经理编号" editable="false"/>
<mx:DataGridColumn dataField="manager_name" headerText="客户经理名称" editable="false"/>
<mx:DataGridColumn dataField="coordinatex" headerText="经度坐标" editable="true"/>
<mx:DataGridColumn dataField="coordinatey" headerText="纬度坐标" editable="true"/>
<mx:DataGridColumn dataField="ship_period" headerText="配送周期" editable="false"/>
<mx:DataGridColumn dataField="ship_line_id" headerText="线路ID" visible="false"/>
<mx:DataGridColumn dataField="ship_line_name" headerText="线路名称" editable="false"/>
<mx:DataGridColumn dataField="customer_no" headerText="专卖证号" visible="false"/>
<mx:DataGridColumn dataField="customer_status" headerText="客户类型" editable="false"/>
<mx:DataGridColumn dataField="customer_status_code" headerText="客户类型编码" visible="false"/>
<mx:DataGridColumn dataField="customer_type_name" headerText="状态" editable="false"/>
<mx:DataGridColumn dataField="customer_start_type" headerText="状态编码" visible="false"/>
<mx:DataGridColumn headerText="操作1" editable="false">
<mx:itemRenderer>
<mx:Component>
<mx:Button label="修改" click="outerDocument.onEdit()"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="操作2" editable="false">
<mx:itemRenderer>
<mx:Component>
<mx:Button label="定位" click="outerDocument.onLocation()"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
</mx:TabNavigator>
<mx:TextArea id="customer_name"
width="99"
x="93" y="11" height="20">
</mx:TextArea>
</mx:Canvas>
</mx:TitleWindow>
相关推荐
在给定的标题“FLEX4 s:dataGrid单元格弹出可文本”中,我们关注的是如何实现点击`DataGrid`的单元格后弹出一个自定义组件,展示更多或更详细的信息。 在Flex4中,我们可以利用事件监听和自定义组件来实现这一功能...
2. **DataGridWithPopUpEditor.as** - 这个文件可能是主datagrid组件的类,其中包含了对自定义编辑器的引用和配置,比如设置哪一列使用这个弹出窗口编辑器,以及相关的事件处理逻辑。 3. **PopUpEditor.mxml** - 这...
Flex DataGrid是一款强大的数据展示组件,常用于Adobe Flex或Flash Builder等开发环境中。它能够高效地展示大量数据,并提供...正确实现前台分页,可以使Flex DataGrid在处理大量数据时表现出优秀的性能和响应速度。
综上所述,Flex 3中通过TitleWindow为DataGrid添加新数据的过程包括创建TitleWindow作为弹出对话框,设计表单获取用户输入,处理“添加”按钮的点击事件以将新数据添加到DataGrid的数据源,以及在主应用中触发...
Flex Datagrid 是Adobe Flex框架中用于展示数据集的组件,它允许开发者以表格形式展示数据,并提供多种交互功能。在Flex应用中,Datagrid经常被用于处理和展示大量的结构化数据。在标题“Flex Datagrid checkbox实现...
当我们处理的数据需要进行分类或者分组时,Flex DataGrid 提供了表头分组的功能,这使得数据的展示更加有条理和易于理解。本文将详细探讨Flex DataGrid的表头分组特性及其实现方式。 首先,表头分组允许我们将数据...
Flex DataGrid 是 Adobe Flex 中一个重要的组件,用于展示结构化数据。它以表格形式呈现,非常适合用来显示多列数据,并提供了排序、选择、编辑等多种功能。在这个教程中,我们将深入探讨 DataGrid 的基本使用和一些...
在Flex开发中,数据网格(DataGrid)是用于展示数据集合的强大组件,它允许用户以表格形式查看和操作数据。本示例关注的是在DataGrid中嵌套复选框(Checkbox),并实现全选功能。这在需要用户批量选择或操作数据的...
本文将详细讨论如何在Flex DataGrid中实现全选和反选功能,并结合`checkBox`来优化这一过程。 首先,我们要理解DataGrid的结构。DataGrid由多个列组成,每一列可能包含不同类型的控件,如文本、图像或复选框。在...
在Flex客户端,接收到服务端的响应后,可以使用Flash Player的navigateToURL方法打开一个新的浏览器窗口,指向服务器返回的Excel文件地址,让用户下载。 在整个过程中,确保处理好错误情况,比如数据解析失败、...
Flex DataGrid 是 Adobe Flex 框架中的一个组件,它用于在应用程序中显示表格数据。在Flex中,实现数据网格的总计功能是一项...通过研究这个示例源代码,可以深入学习Flex DataGrid的使用方法和总计功能的实现技巧。
在Flex开发中,Datagrid组件是用于展示数据集的一个强大工具,它允许用户以表格的形式查看和操作数据。本文将深入探讨如何在Flex的Datagrid中实现数据的合计与平均值计算,帮助开发者更好地理解和应用这些功能。 ...
`DataGrid`是Flex提供的一个可自定义的、可滚动的数据容器,它允许用户以网格形式查看和操作数据。这种组件特别适用于展示大量结构化的信息,例如数据库记录或者报表数据。`DataGrid`可以自动调整列宽,并支持排序、...
原理就是ArrayCollection的filterFunction的使用。是根据老外一个帖子改的,其他下载地址在 :http://www.zuidaima.com/share/1714555305004032.htm
在Flex开发中,数据网格(DataGrid)是一个非常重要的组件,它用于展示和管理大量结构化数据。在标题“flex datagrid doubleclick 实例”中,我们关注的是如何实现DataGrid组件对用户双击事件的响应。双击事件通常...
在Flex开发中,`Datagrid`组件是一种常用的展示数据列表的控件,而分页和数据高亮显示是提升用户体验的重要功能。本篇主要探讨如何在Flex的`Datagrid`中实现分页定位和高亮显示。 首先,分页定位涉及的主要任务是...
flex datagrid 实现合计功能控件包 带源码,demo fxp是flex4的工程文件,导入到工作空间即可 直接导入项目即可。 更多访问我的blog www.dplayer.net
在本文中,我们将深入探讨基于Adobe Flex的DataGrid组件的应用实例。Flex是一种强大的富互联网应用程序(RIA)...在不断探索和实践中,开发者可以不断提升对DataGrid的掌握程度,构建出更高效、更友好的数据管理界面。