简体   繁体   English

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

[英]Remove multiple rows in a Flex Spark datagrid

I want to delete all selected rows in a Spark datagrid. 我想删除Spark数据网格中的所有选定行。

This code below accounts for the Vector indices but I cannot get it to work. 下面的代码说明了Vector索引,但是我无法使其正常工作。 It does not throw out any errors. 它不会抛出任何错误。

What am I doing wrong? 我究竟做错了什么?

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>

您好像忘记了调用deleteItem方法。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM