删除Flex Spark数据网格中的多个行

时间:2014-05-18 17:31:52

标签: flex vector datagrid rows flex-spark

我想删除Spark数据网格中的所有选定行。

下面的代码说明了Vector索引,但我无法让它工作。它不会丢失任何错误。

我做错了什么?

public function deleteItem(event:MouseEvent):void{     
    var sIndices:Vector.<int> = arrayGrid.selectedIndices;
    sIndices.sort(Array.NUMERIC); 

    for(var index:int = sIndices.length-1; index>=0; index--) {
        arrayColl.removeItemAt(sIndices[index]);
    }       
    arrayColl.refresh();
} 

private function convertDateFormat(item:Object,column:GridColumn):String {
    return simpleDate.format(item.itemStartDate);simpleDate.format(item.itemEndDate);
}
]]>
</fx:Script>
<s:VGroup width="100%" height="100%" >
    <s:Button label="Remove Selected Items"/>       
    <s:Button label="Add New Entry" click="newItem()"/>     
    <search:searchBar id="SearchBar" searchListCollection="{arrayColl}"
                      dataGrid="{arrayGrid}"/>
    <s:DataGrid id="arrayGrid" width="100%" height="100%" dataProvider="{arrayColl}" 
                selectionMode="multipleRows" doubleClickEnabled="true">
        <s:columns>
            <s:ArrayList>               
                <s:GridColumn dataField="projectName" headerText="Project Name" />
                <s:GridColumn dataField="tag" headerText="Priority Code" />
                <s:GridColumn width="180" dataField="itemStartDate" 
                      labelFunction="convertDateFormat" headerText="Start Date"/>
                <s:GridColumn width="180" dataField="itemEndDate"  
                      labelFunction="convertDateFormat" headerText="End Date"/>
                <s:GridColumn dataField="notes" headerText="Notes"/>
                <s:GridColumn width="100" dataField="colorCode" headerText="Color HEX"/>
            </s:ArrayList>
        </s:columns>
    </s:DataGrid>

1 个答案:

答案 0 :(得分:1)

看起来您忘了调用deleteItem方法。

<s:Button label="Remove Selected Items" click="deleteItem(event)"/>