I am trying to manage my datagrid using the
dataprovider, so if I
delete the nodes in the data provider (an XmlList) I expect the rows
in the datagrid to be removed too.
Is this a wrong assumption. Please see below?
===start===
<?xml version="1.0"?>
<!-- DataGrid control example. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
private function deleteAll():void{
for (var i:uint=0;i<=employees.length();i++){
delete employees[0];
}
}
private var emp:XML =
<employees>
<employee>
<name>Christina Coenraets</name>
<phone>555-219-2270</phone>
<email>[EMAIL PROTECTED]us.com</email>
<active>true</active>
</employee>
<employee>
<name>Joanne Wall</name>
<phone>555</phone>
<email>[EMAIL PROTECTED]com</email>
<active>true</active>
</employee>
</employees>;
[Bindable]
private var employees:XMLList = emp.employee;
]]>
</mx:Script>
<mx:Panel title="DataGrid Control Example" height="100%"
width="100%"
paddingTop="10" paddingLeft="10" paddingRight="10">
<mx:DataGrid id="dg" width="100%" height="100%"
rowCount="5"
dataProvider="{employees}">
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="Name"/
>
<mx:DataGridColumn dataField="phone"
headerText="Phone"/>
<mx:DataGridColumn dataField="email"
headerText="Email"/>
</mx:columns>
</mx:DataGrid>
<mx:Button label="Delete" click="deleteAll()"/>
</mx:Panel>
</mx:Application>
===end===