最近做一个air的项目,其中用到了FileSystemDataGrid,然而它的name这一列总是太窄了,无法完全的显示全部文件名.而且也找不到哪个属性可以对它进行设置.
后来想我可以继承它然后对里面的属性再进行设置, 嗯,是个好办法,现在就动手来做.
先写个as
然后再写个测试文件
好了,看下效果吧, 下面那个是系统自带的,上面那个是新写的
[img]http://www.iteye.com/upload/picture/pic/39842/b5a162c5-5f1c-3721-9638-da74988bc110-thumb.png?1246504833[/img]
后来想我可以继承它然后对里面的属性再进行设置, 嗯,是个好办法,现在就动手来做.
先写个as
package com.hurlant.util {[color=red]//包名改成自己的[/color]
import mx.controls.FileSystemDataGrid;
import mx.controls.dataGridClasses.DataGridColumn;
public class MyFileSystemDataGrid extends FileSystemDataGrid
{
public function MyFileSystemDataGrid()
{
super();
}
/**
*重写父类的方法,然后对 nameColumn.width重新赋值.
*
*/
override protected function childrenCreated():void
{
super.childrenCreated();
nameColumn.width = 300;
}
}
}
然后再写个测试文件
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication width="1024" height="900" xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" xmlns:ns1="com.hurlant.util.*">
<!--新定义的 -->
<ns1:MyFileSystemDataGrid x="56" y="140"/>
<!--系统自带的 -->
<mx:FileSystemDataGrid x="56" y="437" />
</mx:WindowedApplication>
好了,看下效果吧, 下面那个是系统自带的,上面那个是新写的
[img]http://www.iteye.com/upload/picture/pic/39842/b5a162c5-5f1c-3721-9638-da74988bc110-thumb.png?1246504833[/img]