内容简介:本节主要介绍了Flex DataGrid根据条目某一属性值改变背景颜色,此DataGrid为自定义拓展的,需要的朋友可以参考下
自定义拓展的DataGrid(as类)代码如下:
package czgh.components
{
import flash.display.Sprite;
import mx.controls.DataGrid;
import mx.core.UIComponent;
public class OptionalDataGrid extends DataGrid
{
private var _rowColorFunction:Function;
private var _customed:Boolean;
private var _customerColor:uint=0;
public function OptionalDataGrid()
{
super();
}
override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void
{
color=0XFFFFFF;
if(this._rowColorFunction != null)
{
if (dataIndex < this.dataProvider.length)
{
var item:Object=this.dataProvider.getItemAt(dataIndex);//设定颜色
color=this._rowColorFunction.call(this, item, color);
}
}
super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);
}
override protected function drawHeaderBackground(headerBG:UIComponent):void
{
headerBG.setStyle("borderVisible","false");
}
public function set rowColorFunction(rowColorFunction:Function):void
{
this._rowColorFunction=rowColorFunction;
}
public function get rowColorFunction():Function
{
return this._rowColorFunction;
}
}
}
在mxml中实现自定义的datagrid并使用 其rowColorFunction方法
//通过比较每条记录中dataField为act和stand的大小决定该条记录的背景颜色
private function setCustomColor(item:Object, color:uint):uint
{
if (Number(item["act"])<Number(item["stand"]))
{
return 0x7bbfea;
}
return color;
}
以上所述就是小编给大家介绍的《Flex 自定义DataGrid实现根据条目某一属性值改变背景颜色》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 真正的画廊,左右条目可点击居中,左右条目可滑动
- GWT .hgignore / .gitignore条目
- java – webstart-maven-plugin的新条目打破了应用程序
- CSS 属性篇(七):Display属性
- JavaScript对象之数据属性与访问器属性
- Logback file属性 与 fileNamePattern属性的关系
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Pattern Recognition and Machine Learning
Christopher Bishop / Springer / 2007-10-1 / USD 94.95
The dramatic growth in practical applications for machine learning over the last ten years has been accompanied by many important developments in the underlying algorithms and techniques. For example,......一起来看看 《Pattern Recognition and Machine Learning》 这本书的介绍吧!