我正在尝试实施以下内容:
有人可以提供一些指导吗?
答案 0 :(得分:3)
我假设您要删除行而不是列。以下作品
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical">
<mx:Script>
<![CDATA[
import mx.events.IndexChangedEvent;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
[Bindable]
private var ac:ArrayCollection=new ArrayCollection([{name: "John", shouldDelete: true}, {name: "Joe", shouldDelete: false}, {name: "Jill", shouldDelete: false}])
private function deleteRows()
{
for each (var row:Object in ac)
{
if (row.shouldDelete == true)
{
var i:int=ac.getItemIndex(row);
ac.removeItemAt(i);
}
}
}
]]>
</mx:Script>
<mx:VBox>
<mx:DataGrid id="dg"
dataProvider="{ac}">
<mx:columns>
<mx:DataGridColumn dataField="name">
</mx:DataGridColumn>
<mx:DataGridColumn id="col2"
editorDataField="selected"
rendererIsEditor="true"
dataField="data.shouldDelete">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox label="Test"
selected="{data.shouldDelete}"
change="data.shouldDelete=selected"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:Button label="delete"
id="deleteBtn"
click="deleteRows()"/>
</mx:VBox>
</mx:Application>
答案 1 :(得分:0)
在itemdatabound中,你应该在特定的单元格中给出启用为false ....