inge88
%Europe/Berlin %888 %2006, 21:18
Wéér een vraag...
Ik heb nu dus een component in een datagridcolumn staan, een checkbox. Ik wil dat de items met een aangevinkte checkbox worden verwijderd zodra er op de verwijder button wordt geklikt. Ik kom er weer eens niet uit. Mijn leraar zei dat ik moest kijken naar de itemEditor, maar ik snap er de ballen niet van.
Vrijwel dezelfde code als in mijn andere topic; oplossing uit die topic erin verwerkt :)
main.mxml
<mx:Script>
<![CDATA[
import mx.core.ClassFactory;
private var CheckBoxItemRenderer:ClassFactory = new ClassFactory(CheckBox);
private function init():void
{
CheckBoxItemRenderer.properties = {changeHandler: CheckBoxChangeHandler};
}
private function CheckBoxChangeHandler(event:Event,data:Object): void
{
btnDelete.addEventListener("click", handleDeleteBtn);
}
private function handleDeleteBtn(event : MouseEvent): void
{
/*deleteContents.send({id:CheckBoxItemRenderer});*/
}
</mx:Script>
<mx:HTTPService id="listContents" url="http://localhost:3000/contents/list" useProxy="false" method="GET"/>
<mx:HTTPService id="editContents" url="http://localhost:3000/contents/update" useProxy="false" method="POST" result="listContents.send()"/>
<mx:HTTPService id="deleteContents" url="http://localhost:3000/contents/delete" useProxy="false" method="POST" result="listContents.send()"/>
<mx:HTTPService id="createContents" url="http://localhost:3000/contents/create" useProxy="false" method="POST" result="listContents.send()"
contentType="application/xml">
<mx:request xmlns="">
<contents>
<author>{author.text}</author>
<title>{title.text}</title>
<text>{text.text}</text>
</contents>
</mx:request>
</mx:HTTPService>
<mx:DataGrid width="100%" height="324" id="contents_dg" dataProvider="{listContents.lastResult.contents.content}" y="0">
<mx:columns>
<mx:DataGridColumn itemRenderer="{CheckBoxItemRenderer}" width="150" headerText="Verwijder?"/>
<mx:DataGridColumn headerText="Auteur" dataField="author"/>
<mx:DataGridColumn headerText="Titel" dataField="title"/>
<mx:DataGridColumn headerText="Categorie" dataField="category-id"/>
</mx:columns>
</mx:DataGrid>
<mx:ControlBar horizontalAlign="right">
<mx:Button id="btnDelete" label="Verwijder"/>
</mx:ControlBar>
</mx:Panel>
CheckBox.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:CheckBox change="myChangeHandler(event)" xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
[Bindable]
public var changeHandler:Function;
private function myChangeHandler(event:Event):void{
if(changeHandler != null){
changeHandler(event,data);
}
}
]]>
</mx:Script>
</mx:CheckBox>
Ik heb nu dus een component in een datagridcolumn staan, een checkbox. Ik wil dat de items met een aangevinkte checkbox worden verwijderd zodra er op de verwijder button wordt geklikt. Ik kom er weer eens niet uit. Mijn leraar zei dat ik moest kijken naar de itemEditor, maar ik snap er de ballen niet van.
Vrijwel dezelfde code als in mijn andere topic; oplossing uit die topic erin verwerkt :)
main.mxml
<mx:Script>
<![CDATA[
import mx.core.ClassFactory;
private var CheckBoxItemRenderer:ClassFactory = new ClassFactory(CheckBox);
private function init():void
{
CheckBoxItemRenderer.properties = {changeHandler: CheckBoxChangeHandler};
}
private function CheckBoxChangeHandler(event:Event,data:Object): void
{
btnDelete.addEventListener("click", handleDeleteBtn);
}
private function handleDeleteBtn(event : MouseEvent): void
{
/*deleteContents.send({id:CheckBoxItemRenderer});*/
}
</mx:Script>
<mx:HTTPService id="listContents" url="http://localhost:3000/contents/list" useProxy="false" method="GET"/>
<mx:HTTPService id="editContents" url="http://localhost:3000/contents/update" useProxy="false" method="POST" result="listContents.send()"/>
<mx:HTTPService id="deleteContents" url="http://localhost:3000/contents/delete" useProxy="false" method="POST" result="listContents.send()"/>
<mx:HTTPService id="createContents" url="http://localhost:3000/contents/create" useProxy="false" method="POST" result="listContents.send()"
contentType="application/xml">
<mx:request xmlns="">
<contents>
<author>{author.text}</author>
<title>{title.text}</title>
<text>{text.text}</text>
</contents>
</mx:request>
</mx:HTTPService>
<mx:DataGrid width="100%" height="324" id="contents_dg" dataProvider="{listContents.lastResult.contents.content}" y="0">
<mx:columns>
<mx:DataGridColumn itemRenderer="{CheckBoxItemRenderer}" width="150" headerText="Verwijder?"/>
<mx:DataGridColumn headerText="Auteur" dataField="author"/>
<mx:DataGridColumn headerText="Titel" dataField="title"/>
<mx:DataGridColumn headerText="Categorie" dataField="category-id"/>
</mx:columns>
</mx:DataGrid>
<mx:ControlBar horizontalAlign="right">
<mx:Button id="btnDelete" label="Verwijder"/>
</mx:ControlBar>
</mx:Panel>
CheckBox.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:CheckBox change="myChangeHandler(event)" xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
[Bindable]
public var changeHandler:Function;
private function myChangeHandler(event:Event):void{
if(changeHandler != null){
changeHandler(event,data);
}
}
]]>
</mx:Script>
</mx:CheckBox>