成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

解析三大Flex DataGrid背景色調(diào)試方法

開發(fā) 后端
Flex DataGrid背景顏色調(diào)試的方法你是否了解,這里和大家分享一下如何改變Flex DataGrid單元格(cell),列(column)和行(row)的背景顏色,希望對你有所幫助。

本文和大家重點討論一下Flex DataGrid背景顏色調(diào)試,在Flex運用中經(jīng)常提到的有關(guān)Flex DataGrid問題是如何改變Flex DataGrid單元格(cell),列(column)和行(row)的背景顏色(backgroundcolor)這里對這3種顏色做一個總結(jié)。

Flex DataGrid背景顏色調(diào)試

在Flex運用中經(jīng)常提到的有關(guān)Flex DataGrid問題是如何改變Flex DataGrid單元格(cell),列(column)和行(row)的背景顏色(backgroundcolor)這里對這3種顏色做一個總結(jié)。

1.設(shè)置行(row)的背景色

主要是通過對Flex DataGrid擴(kuò)展,對protected函數(shù)drawRowBackground()進(jìn)行重寫,具體代碼如下:

  1. overrideprotectedfunctiondrawRowBackground(s:Sprite,rowIndex:int,
  2. y:Number,height:Number,color:uint,dataIndex:int):void  
  3. {  
  4. if(dataIndex>=dataProvider.length){  
  5. super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);  
  6. return;  
  7. }  
  8. if(dataProvider.getItemAt(dataIndex).col3<2000){//setcoloraccordinttodatas  
  9. super.drawRowBackground(s,rowIndex,y,height,0xC0C0C0,dataIndex);  
  10. }else{  
  11. super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);  
  12. }  
  13. }  
  14.  

 這段代碼中根據(jù)Flex DataGrid的數(shù)據(jù)源進(jìn)行判斷來設(shè)置背景色,但是它有個缺陷,就是這個具體的背景色我們無法自己靈活指定。因此派生出新的CustomRowColorFlex DataGrid,具體代碼如下:

  1. packagecwmlab.controls  
  2. {  
  3. importmx.controls.*;  
  4. importflash.display.Shape;  
  5. importmx.core.FlexShape;  
  6. importflash.display.Graphics;  
  7. importflash.display.Sprite;  
  8. importmx.rpc.events.AbstractEvent;  
  9. importmx.collections.ArrayCollection;  
  10. importflash.events.Event;  
  11. /**  
  12. *Thisisanextendedversionofthebuilt-inFlexFlex DataGrid.  
  13. *Thisextendedversionhasthecorrectoverridelogicinit  
  14. *todrawthebackgroundcolorofthecells,basedonthevalueofthe  
  15. *dataintherow.  
  16. **/  
  17.  
  18. publicclassCustomRowColorFlex DataGridextendsFlex DataGrid  
  19. {  
  20. privatevar_rowColorFunction:Function;  
  21. publicfunctionCustomRowColorFlex DataGrid()  
  22. {  
  23. super();  
  24. }  
  25. /**  
  26. *Auser-definedfunctionthatwillreturnthecorrectcolorofthe  
  27. *row.Usuallybasedontherowdata.  
  28. *  
  29. *expectedfunctionsignature:  
  30. *publicfunctionF(item:Object,defaultColor:uint):uint  
  31. **/  
  32.  
  33. publicfunctionsetrowColorFunction(f:Function):void  
  34. {  
  35. this._rowColorFunction=f;  
  36. }  
  37.  
  38. publicfunctiongetrowColorFunction():Function  
  39. {  
  40. returnthis._rowColorFunction;  
  41. }  
  42.  
  43. /**  
  44. *Drawsarowbackground  
  45. *atthepositionandheightspecifiedusingthe  
  46. *colorspecified.ThisimplementationcreatesaShapeasa  
  47. *childoftheinputSpriteandfillsitwiththeappropriatecolor.  
  48. *Thismethodalsousesthe<code>backgroundAlpha</code>styleproperty  
  49. *settingtodeterminethetransparencyofthebackgroundcolor.  
  50. *  
  51. *@paramsASpritethatwillcontainadisplayobject  
  52. *thatcontainsthegraphicsforthatrow.  
  53. *  
  54. *@paramrowIndexTherow'sindexinthesetofdisplayedrows.The  
  55. *headerdoesnotcount,thetopmostvisiblerowhasarowindexof0.  
  56. *Thisisusedtokeeptrackoftheobjectsusedfordrawing  
  57. *backgroundssoaparticularrowcanre-usethesamedisplayobject  
  58. *eventhoughtheindexoftheitemthatrowisrenderinghaschanged.  
  59. *  
  60. *@paramyThesuggestedypositionforthebackground  
  61. *@paramheightThesuggestedheightfortheindicator  
  62. *@paramcolorThesuggestedcolorfortheindicator  
  63. *  
  64. *@paramdataIndexTheindexoftheitemforthatrowinthe  
  65. *dataprovider.Thiscanbeusedtocolorthe10thitemdifferently  
  66. *forexample.  
  67. */  
  68.  
  69. overrideprotectedfunctiondrawRowBackground(s:Sprite,rowIndex:int,
  70. y:Number,height:Number,color:uint,dataIndex:int):void  
  71. {  
  72. if(this.rowColorFunction!=null){  
  73. if(dataIndex<this.dataProvider.length){  
  74. varitem:Object=this.dataProvider.getItemAt(dataIndex);  
  75. color=this.rowColorFunction.call(this,item,color);  
  76. }  
  77. }  
  78. super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);  
  79. }  
  80. }  
  81. }  
  82.  

 在具體使用過程中可以這樣調(diào)用:

  1. <cwmlab:CustomRowColorFlex DataGriddataProvider="{dp}" 
  2.  
  3. rowColorFunction="setCustomColor"> 
  4. privatefunctionsetCustomColor(item:Object,color:uint):uint  
  5. {  
  6. if(item['col3']>=2000)  
  7. {  
  8. return0xFF0033;  
  9. }  
  10. returncolor;  
  11. }  
  12.  

 #p#2.設(shè)置Flex DataGrid列的背景色

這個很簡單,只要設(shè)置Flex DataGridColumn的屬性backgroundColor="0x0000CC"即可。

3.設(shè)置Flex DataGrid單元格(cell)的背景色

這個主要通過itemRenderer進(jìn)行設(shè)置,itemRenderer可以是Label,也可以是其他如Flex DataGridItemRenderer。

先看看用Label如何設(shè)置背景色

  1. <mx:Flex DataGridColumnheaderText="Make"dataField="col1"> 
  2. <mx:itemRenderer> 
  3. <mx:Component> 
  4. <mx:Label><!--usinglabelasitemRenderer--> 
  5. <mx:Script><![CDATA[  
  6. overridepublicfunctionsetdata(value:Object):void  
  7. {  
  8. super.data=value;  
  9. if(value.col1=='Toyota'){  
  10. this.opaqueBackground=0xCC0000;  
  11. }  
  12. }  
  13. ]]></mx:Script> 
  14. </mx:Label> 
  15. </mx:Component> 
  16. </mx:itemRenderer> 
  17. </mx:Flex DataGridColumn> 
  18.  

 用Flex DataGridItemRenderer進(jìn)行背景色設(shè)置如下:

  1. <mx:Flex DataGridColumnheaderText="Year"dataField="col3"> 
  2. <mx:itemRenderer> 
  3. <mx:Component> 
  4. <mx:Flex DataGridItemRenderer>
  5. <!--usingFlex DataGridItemRendererasitemRenderer--> 
  6. <mx:Script><![CDATA[  
  7. overridepublicfunctionsetdata(value:Object):void  
  8. {  
  9. super.data=value;  
  10. if(value.col3>=2000){  
  11. this.background=true;  
  12. this.backgroundColor=0x00cc00;  
  13. }  
  14. }  
  15. ]]></mx:Script> 
  16. </mx:Flex DataGridItemRenderer> 
  17. </mx:Component> 
  18. </mx:itemRenderer> 
  19. </mx:Flex DataGridColumn> 
  20.  

【編輯推薦】

  1. 定義Flex DataGrid組件樣式外觀方法指導(dǎo)
  2. 常用FlexBuilder快捷鍵用法指導(dǎo)
  3. Flex框架Riawave的定制應(yīng)用
  4. 技術(shù)前沿 Flex2.0 從零開始實現(xiàn)文件上傳
  5. FlexBuilder開發(fā)方法及特點解析 

 


 

 

責(zé)任編輯:佚名 來源: csdn.net
相關(guān)推薦

2010-08-11 16:41:30

Flex DataGr

2010-08-13 14:39:57

Flex布局

2010-07-28 13:48:49

Flex數(shù)據(jù)綁定

2021-04-16 05:54:05

CSS 文字動畫技巧

2024-01-30 13:53:31

2010-08-09 14:54:58

Flex全屏

2010-08-06 14:13:31

FlexDataGrid分頁控

2010-08-11 16:10:27

Flex DataGr

2022-12-26 11:25:25

CSS黑白文字

2010-08-11 16:03:02

Flex DataGr

2010-08-13 13:39:51

Flex效果組件

2010-07-30 13:15:17

Flex優(yōu)勢

2010-08-04 11:04:58

Flex框架

2024-05-08 08:42:58

TypeScript函數(shù)文本顏色

2010-07-29 15:44:54

Flex安全沙箱

2010-07-29 14:58:49

Flex全屏模式

2010-08-05 13:33:06

Flex布局規(guī)則

2010-07-27 13:53:15

Flex ComboB

2010-07-30 14:32:50

Flex應(yīng)用

2010-08-10 13:42:27

Flex開源項目
點贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 美日韩视频 | 国产成人免费视频网站视频社区 | 三级av在线 | 国产美女网站 | 欧美jizzhd精品欧美巨大免费 | 97操操 | 很很干很很日 | 澳门永久av免费网站 | av国产精品 | 天天综合91 | 亚洲成人av| 日韩免费福利视频 | 黄a在线观看 | 国产精品99免费视频 | 丁香婷婷在线视频 | 久久香蕉精品视频 | 在线观看中文字幕一区二区 | 欧美日韩成人在线观看 | 中文精品视频 | www亚洲精品| 不卡一区二区在线观看 | 久久一区二区视频 | 天天欧美| 999re5这里只有精品 | 在线看亚洲 | 国产亚洲精品久久久久久豆腐 | 欧美久久久久久久久中文字幕 | 精品国产成人 | 亚洲一本 | 亚洲精品久久久久久久久久久 | 成人黄色电影在线观看 | 日韩欧美亚洲 | 久久久久国产视频 | 日韩国产精品一区二区三区 | 最新中文字幕第一页视频 | 99精品视频免费观看 | 午夜国产一级 | 黄色网络在线观看 | 女人一区| 久久久国产一区二区三区四区小说 | 伊人网综合在线观看 |