Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex AdvancedDataGrid listItems strange behaviour
    primarykey
    data
    text
    <p>I have the following XML, that is the dataprovider (as a Hierarchicaldata) of an Advanced DataGrid:</p> <pre><code>public var reqData:XML = &lt;root&gt; &lt;Requirement ID="REQ-GEN-0.1" title="exigence gen 1" description="blabla 01" testable="true"/&gt; &lt;RequirementSet ID="GUI REQ"&gt; &lt;Requirement ID="REQ-GUI-1.1" title="exigence ihm 1" description="blabla 11" testable="true"/&gt; &lt;Requirement ID="REQ-GUI-1.2" title="exigence ihm 2" description="blabla 12" testable="false"/&gt; &lt;/RequirementSet&gt; &lt;RequirementSet ID="PERF REQ"&gt; &lt;Requirement ID="REQ-PERF-2.1" title="exigence perf 1" description="blabla 21" testable="true"/&gt; &lt;Requirement ID="REQ-PERF-2.2" title="exigence perf 2" description="blabla 22" testable="false"/&gt; &lt;Requirement ID="REQ-PERF-2.3" title="exigence perf 3" description="blabla 23" testable="true"/&gt; &lt;Requirement ID="REQ-PERF-2.4" title="exigence perf 4" description="blabla 24" testable="false"/&gt; &lt;Requirement ID="REQ-PERF-2.5" title="exigence perf 5" description="blabla 25" testable="false"/&gt; &lt;Requirement ID="REQ-PERF-2.6" title="exigence perf 6" description="blabla 26" testable="false"/&gt; &lt;/RequirementSet&gt; &lt;RequirementSet ID="BUS REQ"&gt; &lt;RequirementSet ID="BUS 1 REQ"&gt; &lt;Requirement ID="REQ-BUS-3.1.1" title="exigence bus 1" description="blabla 311" testable="false"/&gt; &lt;Requirement ID="REQ-BUS-3.1.2" title="exigence bus 2" description="blabla 312" testable="true"/&gt; &lt;/RequirementSet&gt; &lt;RequirementSet ID="BUS 2 REQ"&gt; &lt;Requirement ID="REQ-BUS-3.2.1" title="exigence bus3" description="blabla 321" testable="true"/&gt; &lt;/RequirementSet&gt; &lt;RequirementSet ID="BUS 3 REQ"/&gt; &lt;RequirementSet ID="BUS 4 REQ"&gt; &lt;Requirement ID="REQ-BUS-3.4.1" title="exigence bus4" description="blabla 341" testable="false"/&gt; &lt;/RequirementSet&gt; &lt;RequirementSet ID="BUS 5 REQ"/&gt; &lt;RequirementSet ID="BUS 6 REQ"/&gt; &lt;/RequirementSet&gt; &lt;/root&gt;; </code></pre> <p>And here is the AdvancedDataGrid part:</p> <pre><code>&lt;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"&gt; &lt;mx:columns&gt; &lt;mx:AdvancedDataGridColumn dataField="@ID" headerText="ID"/&gt; &lt;mx:AdvancedDataGridColumn dataField="@title" headerText="Titre"/&gt; &lt;mx:AdvancedDataGridColumn dataField="@testable" headerText="Testable"/&gt; &lt;mx:AdvancedDataGridColumn dataField="@description" headerText="Description" editorUsesEnterKey="true" wordWrap="true"/&gt; &lt;/mx:columns&gt; &lt;/mx:AdvancedDataGrid&gt; </code></pre> <p>The problem is that when I look at the listItems' length of the AdvancedDataGrid, it is 19 at the creation, and then 16 that is totally wrong (22 items). I want to access to some items and I can't which is really annoying. Is it a bug or something?</p> <p><strong>NOTE:</strong></p> <p>To access items by rowIndex and columnIndex I'm doing the following:</p> <pre><code>var advancedDataGridListData:AdvancedDataGridListData = IDropInListItemRenderer(listItems[event.rowIndex][event.columnIndex]).listData as AdvancedDataGridListData; IHierarchicalCollectionView(dataProvider).getChildren( advancedDataGridListData.item) </code></pre> <p><strong>EDITED 23/02/2012</strong></p> <p>I tested your solution with event.item but unfortunatly this item was always null and I didn't understand why. So I looked deeper into the source code of AdvancedDataGridBaseEx and I found that this is a part of the Adobe source code):</p> <pre><code>// 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); </code></pre> <p>You can see that the event.item is never filled!!!! Thanks Adobe... I will try your other solution then I give you feedback.</p> <p><strong>LAST EDIT</strong></p> <p>I solved my problem by using in my custom datagrid:</p> <pre><code>var xmlNode:XML = this.selectedItem as XML; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COI'm confused... shouldn't you be looking at the dataProvider, I believe the listItems keeps track of the renderers which are dynamically created and recycled, hence the changing count (if you scale the app so there's less area to draw you should see an even lower number in listItems I believe).
      singulars
    2. COThe problem is that I have to access to items by rowIndex and columnIndex. I have an ITEM_EDIT_BEGINNING event and I want to filter the items that can be edited. The event just returns rowIndex and columnIndex and I thought it was the way to access items: var advancedDataGridListData:AdvancedDataGridListData = IDropInListItemRenderer(listItems[event.rowIndex][event.columnIndex]).listData as AdvancedDataGridListData;
      singulars
    3. COThat part should work out fine are you getting null object references when using that code or are you just worried about the changing size of listItems? To iterate across the entire collection just use dataProvider or dataProvider.source; the dataProvider should stay consistent with regard to length aside from if a filterFunction is applied. listItems will change depending on what is shown on screen (and a couple of extra offscreen renderers that are made to basically give it some read ahead so rows just off screen are ready for display in advance).
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload