찾다
php教程PHP开发Flex 사용자 정의 DataGrid는 항목의 특정 속성 값을 기반으로 배경색 변경을 구현합니다.

사용자 정의 확장 DataGrid(클래스) 코드는 다음과 같습니다.

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 Custom Define DataGrid 항목의 특정 속성 값을 기반으로 배경색 변경을 구현하려면 관련 기사를 보려면 PHP 중국어 웹사이트를 주목하세요!

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

PhpStorm 맥 버전

PhpStorm 맥 버전

최신(2018.2.1) 전문 PHP 통합 개발 도구

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

SublimeText3 영어 버전

SublimeText3 영어 버전

권장 사항: Win 버전, 코드 프롬프트 지원!

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

Dreamweaver Mac版

Dreamweaver Mac版

시각적 웹 개발 도구