读书人

flex Tree控件 只需要叶子节点带check

发布时间: 2012-04-15 18:39:21 作者: rapoo

flex Tree控件 只需要叶子节点带checkbox如何实现啊?
flex Tree控件 只需要叶子节点带checkbox如何实现啊?

[解决办法]
public class TreeCheckBoxRenderer extends TreeItemRenderer
{
public function TreeCheckBoxRenderer()
{
super();
}

private var checkBox:CheckBox;

public var _selectedField:String;

override protected function createChildren():void
{
super.createChildren();

checkBox = new CheckBox();
checkBox.setStyle("verticalAlign", "middle");
checkBox.visible = false;
addChild(checkBox);
}

override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if (data)
{
var tree:Tree = Tree(listData.owner);
if (tree.dataDescriptor.isBranch(data))
{
checkBox.visible = true;

if (super.icon != null)
{
checkBox.x = super.icon.x;
super.icon.x = checkBox.x + checkBox.width + 17;
super.label.x = super.icon.x + super.icon.width + 3;
}
else
{
checkBox.x = super.label.x;
super.label.x = checkBox.x + checkBox.width + 17;
}
checkBox.y = (unscaledHeight - checkBox.height) / 2;
}

}
}
}

读书人网 >flex

热点推荐