Flex: Setting Datagrid column percentWidth – 设置Datagrid 列宽度为百分比

Categories: Flex; Tagged with: ; @ August 19th, 2010 22:31

需求: 设置DatagridColumn的Percent width

临时解决方法: 监听Datagrid的CREATION_COMPLETE事件, 在响应函数中重置Column的宽度.

效果: 参见http://cutown.com/home/reg.php, 网页内嵌入的Datagrid中, 后两列宽度为首列之外的宽度均分.

代码:

	/** Datagrid创建完毕后设定Column的宽度. */
	protected function onDGCreationComplte(e:Event):void {
		var columnServerID:DataGridColumn = columns[0] as DataGridColumn;

		for(var i:int = 0; i < columns.length; i++) {
			var column:DataGridColumn = columns[i] as DataGridColumn;
			column.width = width/columns.length; // 重设宽度, 减去首列宽度, 其他列均分.
		}
	}

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.