【发布时间】:2011-04-10 20:47:04
【问题描述】:
我遇到了一个有趣的问题,并认为值得发布:
在我必须在运行时使用分层数据设置数据提供者的情况下,我使用了高级数据网格。 adobe 文档并没有真正涵盖这种事情(至少在我可以挖掘到的水平上)。
以前有人遇到过这种情况吗?
我唯一能想到的是有点骇人听闻,并且似乎在高级网格的披露图标中引入了一些奇怪的行为。我在下面包含了一个测试用例:
advancedDataGridProblem.as:
import mx.collections.ArrayCollection;
public var dataProvider:ArrayCollection = new ArrayCollection([{label:"item1"},
{label:"item2", children:[{label:"subItem1"},{label:"subItem2"},
{label:"subItem3"}]},
{label:"item3"}]);
public function init():void{
//using callLater to ensure that the grid has been created before setting DP
this.callLater(setDataProvider,[dataProvider]);
}
public function setDataProvider(list:ArrayCollection):void{
heirData.source = list;
}
和mxml:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script source="advancedDataGridProblem.as"/>
<mx:AdvancedDataGrid id="advDG" width="100%">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="What the heck?"/>
<mx:AdvancedDataGridColumn headerText="Label" dataField="label"/>
<mx:AdvancedDataGridColumn headerText="Column 2"/>
<mx:AdvancedDataGridColumn headerText="Column 3"/>
</mx:columns>
<mx:dataProvider>
<mx:HierarchicalData id="heirData"/>
</mx:dataProvider>
</mx:AdvancedDataGrid>
</mx:Application>
正如您在运行测试应用程序时所看到的,应该显示在“标签”列中的图标实际上被放置在“What the heck?”中。柱子。如果您将 Label 列拖过来并尝试将其与“What the heck?”交换。列,图标保持在原来的位置,但神奇的是,以前为“标签”列左对齐的标签现在为图标设置了适当的格式。将“标签”列拖出插槽 1 会将网格恢复为原始状态。
这个有点超出我的想象 - 有人有什么建议吗?
理想情况下,我想一起解决这个问题,并在运行时像往常一样分配 dataProvider。
提前致谢!
我将很快向 adobe 提交一份关于此问题的错误报告,并将链接放入评论中。
【问题讨论】:
标签: flex3 advanceddatagrid dataprovider hierarchical disclosure