最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Flex動態(tài)生成可編輯的DataGrid具體實現(xiàn)代碼

 更新時間:2013年04月25日 14:52:27   作者:  
DataGrid具有以下功能:表頭是動態(tài)生成的、每行都是有序號的、每行都是可以編輯、插入、刪除、修改,接下來為大家分享下Flex如何動態(tài)生成可編輯的DataGrid
一:先說說我寫這個DataGrid具有的功能
1、表頭是動態(tài)生成的。
2、每行都是有序號的。
3、每行都是可以編輯、插入、刪除、修改的。
4、每個單元格都是加驗證的。
5、單元格有些是經(jīng)過渲染生成的比如:Combobox,DateField...

二、說一些實現(xiàn)這些功能的困難
寫這個的時候感覺都是困難不知道,走過來了也就木有神馬啦,最讓我費勁的就是渲染例如:Combobox在渲染的時候不能用ItemRenderer因為他不能綁定值,只能用ItemEditor但是怎樣獲得這個一個經(jīng)過渲染的對象,通過百度不斷地百度,終于發(fā)現(xiàn)了ClassFactory這個工廠可以生產(chǎn)各種想要的組件。各種困難現(xiàn)在都記不起來了,三天時間終于完成啦。為什嗎要這樣寫呢?因為要做數(shù)據(jù)更新系統(tǒng),每年數(shù)據(jù)都會有變化,這樣頁面也需要變化,總不能每年都去改源碼吧,不如想個法子全給他整成動態(tài)的。這就是寫這個的初衷。

三、關(guān)鍵源碼
復(fù)制代碼 代碼如下:

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{
//應(yīng)該在這里查詢數(shù)據(jù)庫
var f:ClassFactory=new ClassFactory(ComboBox);
f.properties={dataProvider: arr,labelField:label,selectedIndex:'0',selectedItem:'石質(zhì)路面'};//添加屬性,綁定選擇狀態(tài)
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:'否'};//添加屬性,綁定選擇狀態(tài)
return f;
}
public static function getDateRenderer():ClassFactory{
var f:ClassFactory=new ClassFactory(DateField);
f.properties={formatString:"YYYY-MM-DD",showToday:true};//添加屬性,綁定選擇狀態(tài)
return f;
}
/*本來想在這渲染生成驗證器的,無奈技術(shù)在達(dá)不到*/
public static function getValidateRenderer():ClassFactory{
var f:ClassFactory=new ClassFactory(RegExpValidator);
f.properties={ source:"roadcode",
property:"text" ,
expression:"^[0-9]*$",
noMatchError:"填寫驗證不通過時顯示他提示信息" };//添加屬性,綁定選擇狀態(tài)
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;
}
}
}

以上代碼是渲染器部分。

相關(guān)文章

最新評論

柘城县| 塔河县| 武夷山市| 富阳市| 广饶县| 重庆市| 襄垣县| 北票市| 大洼县| 海淀区| 井陉县| 阜康市| 关岭| 黔南| 定西市| 晋州市| 曲靖市| 乐昌市| 芜湖市| 白山市| 新疆| 阜新市| 四子王旗| 定西市| 德安县| 昌平区| 南雄市| 开鲁县| 景东| 闵行区| 革吉县| 亳州市| 鹿邑县| 房产| 兴业县| 文安县| 中卫市| 河南省| 民乐县| 滕州市| 中江县|