PDA

Volledige versie bekijken : class properties


Beapat
%Europe/Berlin %933 %2011, 22:23
Hallo iedereen ik moet een projectje maken waar ik gebruik maak van customcomponent om een arraycollection te vullen. Daarvoor moet ik ze omvormen tot class properties. Ik krijg telkens een lege lijst en begrijp eigenlijk niet goed waar de fout zit. Kan iemand helpen?
Dit is de code van de custom component
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
[Bindable]
public var boekske:Object;
]]>
</fx:Script>
<s:VGroup>
<s:Label text="Booklist"/>
<s:DataGrid id="grid" requestedRowCount="5" dataProvider="{boekske}">
<s:columns>
<s:ArrayList>
<s:GridColumn width="350" dataField="title" headerText="Title"></s:GridColumn>
<s:GridColumn width="75" dataField="price" headerText="Price"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
<s:Button id="btn_remove" label="Remove book"/>
</s:VGroup>
</s:Group>

En dit van de applicatie zelf.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:components="components.*">

<fx:Script>
<![CDATA[

import mx.collections.ArrayCollection;

import spark.components.DataGrid;

// public function verwijderboek():void
//{
// if(grid.selectedIndex!=-1)
// {
//als er niet geklikt is = -1 -> kan je opzoeken in debugger
// MijnArray.removeItemAt(grid.selectedIndex);
// }
//}

]]>
</fx:Script>

<fx:Declarations>
<fx:Model id="boeken" source="/data/books.xml"/>
<fx:Model id="authors" source="/data/authors.xml"/>
<s:ArrayCollection id="MijnArray" source="{boeken.book}"/>
<s:ArrayCollection id="Mijnauthors" source="{authors.author}"/>
<!--Om een model te gebruiken worden de gegevens achteraf in een array gestopt -> arraycollection-->
</fx:Declarations>



<s:VGroup x="89" y="66" width="489" height="296">

<components:header>

</components:header>

<s:HGroup width="489" height="176">
<s:VGroup width="101" height="176">
<s:Button id="btn_catalog" label="Catalog" click="view1.selectedChild=books"/>
<s:Button id="btn_authors" label="Authors" click="view1.selectedIndex=1"/>
<s:Button id="btn_shopping" label="Shopping Cart" click="view1.selectedIndex=2"/>
</s:VGroup>

<s:VGroup width="381" height="176">
<mx:ViewStack id="view1">

<s:NavigatorContent width="100%" height="100%" label="boeken" id="books">
<components:boeken boekske="MijnArray">

</components:boeken>
</s:NavigatorContent>

<s:NavigatorContent width="100%" height="100%" label="authors" >
<s:VGroup>
<s:Label text="Authorlist"/>
<s:DataGrid id="au" dataProvider="{Mijnauthors}">
<s:columns>
<s:ArrayList>
<s:GridColumn width="200" dataField="au_fname" headerText="Firstname"></s:GridColumn>
<s:GridColumn width="200" dataField="au_lname" headerText="Lastname"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>
</s:VGroup>
</s:NavigatorContent>

<s:NavigatorContent width="100%" height="100%" id="shop">
<s:VGroup>
<s:Label text="Shopping Cart"/>
<s:Label text="your shopping cart is empty"/>
</s:VGroup>
</s:NavigatorContent>

</mx:ViewStack>
</s:VGroup>
</s:HGroup>
</s:VGroup>
</s:Application>