検索
ホームページ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 でカスタム データグリッドを実装し、その 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 は、データグリッドの特定の属性値に基づいて背景色の変更を実装します。エントリー 関連記事 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ヘンタイを無料で生成します。

ホットツール

PhpStorm Mac バージョン

PhpStorm Mac バージョン

最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

SublimeText3 英語版

SublimeText3 英語版

推奨: Win バージョン、コードプロンプトをサポート!

AtomエディタMac版ダウンロード

AtomエディタMac版ダウンロード

最も人気のあるオープンソースエディター

Dreamweaver Mac版

Dreamweaver Mac版

ビジュアル Web 開発ツール