Data grid render which knows what column it’s rendering:
It is supposed to do the same job as the previous renderer – it renders columns lines differently if the data row has ‘is_admin’ field set. However, the following renderer is flickering!
package {
import mx.controls.DataGrid;
import mx.controls.dataGridClasses.DataGridItemRenderer;
import mx.controls.dataGridClasses.DataGridListData;
import mx.controls.Text;
import mx.controls.dataGridClasses.DataGridColumn;
public class MemberRenderer extends DataGridItemRenderer {
public function MemberRenderer() { super(); }
private var lastUID:String; // the last thing we rendered
override public function set data(value:Object):void {
super.data = value;
if (listData && listData.uid != lastUID) {
//styleChanged(“color”);
var dgListData:DataGridListData = listData as DataGridListData;
var dataGrid:DataGrid = dgListData.owner as DataGrid;
var column:DataGridColumn = dataGrid.columns[dgListData.columnIndex];
if (value.is_admin == true) {
styleName = “adminStyle”;
}
text = data[column.dataField];
lastUID = listData.uid;
}
}
}
}
Just me, but I never trust the operator order of precedence; I use parentheses to insure that the operations are doing what I think they are:
if ((listData != null) && (listData.uid != lastUID))
Comment by Richard C Haven — January 24, 2009 @ 9:48 pm |