Flex动态生成可编辑的DataGrid具体实现代码(flex补丁合并教程)一看就会

随心笔谈12个月前发布 admin
102 0

package datagridview

{

import com.adobe.serialization.json.JSON;

import com.jzh.test.ComboxColumn;

import com.jzh.test.ComboxItem;

import mx.collections.ArrayCollection;

import mx.controls.Alert;

import mx.controls.ComboBase;

import mx.controls.ComboBox;

import mx.controls.DateField;

import mx.controls.RadioButtonGroup;

import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;

import mx.core.ClassFactory;

import mx.validators.RegExpValidator;

import spark.components.DropDownList;

public class RendererUtil

{

public function RendererUtil()

{

}

public static function getButtonRenderer():ClassFactory{

var f:ClassFactory=new ClassFactory(OperateButtons);

f.properties={};

return f;

}

public static function getNumRenderer():ClassFactory{

var f:ClassFactory=new ClassFactory(numLabel);

f.properties={};

return f;

}

public static function getComboxRenderer(arr:ArrayCollection,label:String):ClassFactory{

//应该在这里查询数据库

var f:ClassFactory=new ClassFactory(ComboBox);

f.properties={dataProvider: arr,labelField:label,selectedIndex:’0′,selectedItem:’石质路面’};//添加属性,绑定选择状态

return f;

}

public static function getRadioRenderer(label:String):ClassFactory{

var f:ClassFactory=new ClassFactory(ComboBox);

var arr:ArrayCollection=new ArrayCollection();

arr.addItem(“是”);

arr.addItem(“否”);

f.properties={dataProvider: arr,labelField:label,selectedIndex:’0′,selectedItem:’否’};//添加属性,绑定选择状态

return f;

}

public static function getDateRenderer():ClassFactory{

var f:ClassFactory=new ClassFactory(DateField);

f.properties={formatString:”YYYY-MM-DD”,showToday:true};//添加属性,绑定选择状态

return f;

}

public static function getValidateRenderer():ClassFactory{

var f:ClassFactory=new ClassFactory(RegExpValidator);

f.properties={ source:”roadcode”,

property:”text” ,

expression:”^[0-9]*$”,

noMatchError:”填写验证不通过时显示他提示信息” };//添加属性,绑定选择状态

return f;

}

public static function getRenderer(label:String,callback:Function=null):ClassFactory{

var f:ClassFactory=new ClassFactory(numLabel);

f.properties={lab:label,callback:callback};

return f;

}

}

}

© 版权声明

相关文章