Flex控件->Datagrid&AdvancedDataGrid&DataGroup&List

本文介绍如何操作Flex中的DataGrid与DataGroup组件,包括隐藏DataGrid的头部、更新DataGrid的数据、锁定DataGrid的列、绘制DataGroup边框等技巧,并详细解释ItemRenderer与ItemEditor的区别。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[color=red]如何隐藏DataGrid的Header?[/color]
dataGrid.showHeaders = false

[color=red]为啥我更新了DataGrid的dataProvider的item的属性值,DataGrid控件却没有自动更新?[/color]
需要调用调用DataGrid的itemUpdate函数进行更新

示例代码:
myCollection.itemUpdated(collectionOfThoseClasses.getItemAt(0));

参考链接:
[url]http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf668d2-7fe7.html[/url]

[color=red]如何锁住DataGrid的某些列,让其不随滚动条滚动?[/color]
利用DataGrid的lockedColumnCount。
示例代码如下:
    <mx:DataGrid id="dataGrid"
lockedColumnCount="1"
horizontalScrollPolicy="on"
width="300">



[color=red]如何为DataGroup绘制边框?[/color]
使用s:Rect。示例代码如下:
    <s:Rect  height="100" verticalCenter="0" width="500" horizontalCenter="2">
<s:stroke>
<s:LinearGradientStroke rotation="90">
<s:GradientEntry color="0x999999" />
<s:GradientEntry color="0xD8D8D8" />
</s:LinearGradientStroke>
</s:stroke>
</s:Rect>

<s:DataGroup id="datagroup" height="100" verticalCenter="0" dataProvider="{itemList}" itemRenderer="itemRenderer" width="500" horizontalCenter="0">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
</s:DataGroup>


[color=red]如何为s:List设置背景色?[/color]
通过s:List的属性contentBackgroundColor可以为其设置背景。

[color=red]如何让DataGrid滚动到特定行?[/color]
1.dataGrid.scrollToIndex(rowIndex);
2.dataGrid.verticalScrollPosition = rowIndex;
上边的两种方法中,scrollToIndex只会保证rowIndex所对应的列在可视范围内,而使用verticalScrollPosition则可以保证rowIndex对应的列为可视范围内的第一行。

[color=red]如何获取DataGroup选中项的相关数据?[/color]
DataGroup并不响应ListEvent,可以在其ItemRenderer的Click处理函数里或者选中项的相关信息,示例代码如下:


<s:ItemRenderer click="handleClick()">

private function handleClick():void
{
trace("item " + itemIndex + " clicked : " + data);
}


[color=red]ItemEditor和ItemRenderer有什么区别?[/color]
[table]
| |显示|编辑|编辑控件是否显示
|ItemRenderer: |总是显示|只有rendererIsEditor为true时可以编辑|总是显示|
|ItemEditor: |总是显示|总是可以|只有编辑时显示|
[/table]
具体差异请仔细比较下边两幅图:
非编辑状态:
[img]http://dl.iteye.com/upload/attachment/334714/892b28b5-7dab-328a-ae7a-006900a7745c.png[/img]
编辑状态:
[img]http://dl.iteye.com/upload/attachment/334716/d24d4595-d519-3578-a1f4-0cd8cb778356.png[/img]

参考资料:http://www.necst.co.jp/product/ibiz/column/flex/chap17.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值