我尝试在所选行下方的 adg 中插入一个新行。
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955"
minHeight="600">
<fx:Script>
<![CDATA[
import mx.collections.XMLListCollection;
import mx.events.FlexEvent;
[Bindable]
protected var worklist:XMLListCollection;
protected var xml:XML=<items>
<item><value>1</value></item>
<item><value>2</value></item>
<item><value>3</value></item>
<item><value>4</value></item>
</items>;
protected function adg_creationCompleteHandler(event:FlexEvent):void
{
var list:XMLList=xml.item;
worklist=new XMLListCollection(list);
trace(worklist);
}
protected function createBut_clickHandler(event:MouseEvent):void
{
var xml:XML=<item/>;
var selInd:int=adg.selectedIndex;
var insertPos:int=selInd + 1;
worklist.addItemAt(xml, insertPos);
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<mx:AdvancedDataGrid id="adg"
dataProvider="{worklist}"
creationComplete="adg_creationCompleteHandler(event)">
<mx:groupedColumns>
<mx:AdvancedDataGridColumn dataField="value"/>
</mx:groupedColumns>
</mx:AdvancedDataGrid>
<s:Button id="createBut"
label="createRow"
click="createBut_clickHandler(event)"/>
这工作正常,直到我先对列进行排序。然后新行将放置在第一个或最后一个索引处,而不是指定索引处。如何使用一般排序功能并将新行放置在特定索引处,即使列值为空?