我有以下XML,即Advanced DataGrid的数据提供者(作为Hierarchicaldata):
public var reqData:XML = <root>
<Requirement ID="REQ-GEN-0.1" title="exigence gen 1" description="blabla 01" testable="true"/>
<RequirementSet ID="GUI REQ">
<Requirement ID="REQ-GUI-1.1" title="exigence ihm 1" description="blabla 11" testable="true"/>
<Requirement ID="REQ-GUI-1.2" title="exigence ihm 2" description="blabla 12" testable="false"/>
</RequirementSet>
<RequirementSet ID="PERF REQ">
<Requirement ID="REQ-PERF-2.1" title="exigence perf 1" description="blabla 21" testable="true"/>
<Requirement ID="REQ-PERF-2.2" title="exigence perf 2" description="blabla 22" testable="false"/>
<Requirement ID="REQ-PERF-2.3" title="exigence perf 3" description="blabla 23" testable="true"/>
<Requirement ID="REQ-PERF-2.4" title="exigence perf 4" description="blabla 24" testable="false"/>
<Requirement ID="REQ-PERF-2.5" title="exigence perf 5" description="blabla 25" testable="false"/>
<Requirement ID="REQ-PERF-2.6" title="exigence perf 6" description="blabla 26" testable="false"/>
</RequirementSet>
<RequirementSet ID="BUS REQ">
<RequirementSet ID="BUS 1 REQ">
<Requirement ID="REQ-BUS-3.1.1" title="exigence bus 1" description="blabla 311" testable="false"/>
<Requirement ID="REQ-BUS-3.1.2" title="exigence bus 2" description="blabla 312" testable="true"/>
</RequirementSet>
<RequirementSet ID="BUS 2 REQ">
<Requirement ID="REQ-BUS-3.2.1" title="exigence bus3" description="blabla 321" testable="true"/>
</RequirementSet>
<RequirementSet ID="BUS 3 REQ"/>
<RequirementSet ID="BUS 4 REQ">
<Requirement ID="REQ-BUS-3.4.1" title="exigence bus4" description="blabla 341" testable="false"/>
</RequirementSet>
<RequirementSet ID="BUS 5 REQ"/>
<RequirementSet ID="BUS 6 REQ"/>
</RequirementSet>
</root>;
这是AdvancedDataGrid部分:
<mx:AdvancedDataGrid id="reqADGtest" displayItemsExpanded="true"
width="95%" height="75%" horizontalCenter="0"
contentBackgroundAlpha="0.0" chromeColor="0xdbeaff"
openDuration="500" dragEnabled="true" dropEnabled="true"
dragMoveEnabled="true" editable="true"
variableRowHeight="true" horizontalScrollPolicy="auto">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="@ID" headerText="ID"/>
<mx:AdvancedDataGridColumn dataField="@title" headerText="Titre"/>
<mx:AdvancedDataGridColumn dataField="@testable" headerText="Testable"/>
<mx:AdvancedDataGridColumn dataField="@description" headerText="Description"
editorUsesEnterKey="true"
wordWrap="true"/>
</mx:columns>
</mx:AdvancedDataGrid>
问题在于,当我查看listItems的AdvancedDataGrid的长度时,它在创建时为19,然后16则完全错误(22项)。我想访问一些项目,我不能真正讨厌。这是一个错误还是什么?
注意:
要通过rowIndex和columnIndex访问项目,我正在执行以下操作:
var advancedDataGridListData:AdvancedDataGridListData =
IDropInListItemRenderer(listItems[event.rowIndex][event.columnIndex]).listData
as AdvancedDataGridListData;
IHierarchicalCollectionView(dataProvider).getChildren(
advancedDataGridListData.item)
EDITED 23/02/2012
我用event.item测试了你的解决方案但不幸的是这个项目总是为空而且我不明白为什么。所以我深入研究了AdvancedDataGridBaseEx的源代码,发现这是Adobe源代码的一部分):
// send event to create the new one
var advancedDataGridEvent:AdvancedDataGridEvent =
new AdvancedDataGridEvent(AdvancedDataGridEvent.ITEM_EDIT_BEGINNING, false, true);
// ITEM_EDIT events are cancelable
advancedDataGridEvent.columnIndex = columnIndex;
advancedDataGridEvent.dataField = _columns[columnIndex].dataField;
advancedDataGridEvent.rowIndex = rowIndex;
dispatchEvent(advancedDataGridEvent);
你可以看到event.item永远不会被填充!!!!感谢Adobe ...我会尝试您的其他解决方案,然后我会给您反馈。
最后编辑
我通过在自定义数据网格中使用来解决我的问题:
var xmlNode:XML = this.selectedItem as XML;
答案 0 :(得分:0)
这个怎么样
dataProvider.getChildren(event.item)
或许也许这种方法会有所帮助(虽然它受到保护,所以你可能需要做一个“猴子补丁”来将访问控制修饰符从protected更改为public:
我认为在event.rowIndex和event.columnIndex它基本上给你绝对值,但listItems基于当前可见的而不是绝对位置。我知道这不是一个直接的答案,但现在已经很晚了。