J'ai un composant personnalisé dont un objet advancedDataGrid est à l'intérieur. Je veux que ce composant soit réutilisable, donc le besoin est de définir le paramètre selectionMode comme propriété de composant.Composant personnalisé dataGrid selectionMode en tant que propriété
Dans MXML je veux définir la propriété comme ceci:
<comp:MyComp itemDataGridSelectionMode="singleCell" .../>
intérieur Mycomp actionScript j'ai un metatag comme ceci:
[Inspectable(enumeration="singleRow, multipleRows, singleCell, multipleCells", defaultValue="singleRow")]
public var itemDataGridSelectionMode:String;
Comment lier cette variable i ne de itemDataGridSelectionMode à AdvancedDatagrid selectionMode?
MISE À JOUR: Voici une petite application de test code de travail entièrement:
<!--MyComp.mxml-->
<?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="638" height="500">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
[Inspectable(enumeration="singleRow, multipleRows, singleCell, multipleCells", defaultValue="singleRow")]
public function set itemsSelectionMode(value:String):void
{
this.adgItems.selectionMode = value;
}
public function get itemsSelectionMode():String
{
return this.adgItems.selectionMode;
}
]]>
</fx:Script>
<mx:AdvancedDataGrid id="adgItems" designViewDataType="flat" width="100%" height="100%">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="Column 1" dataField="col1"/>
<mx:AdvancedDataGridColumn headerText="Column 2" dataField="col2"/>
<mx:AdvancedDataGridColumn headerText="Column 3" dataField="col3"/>
</mx:columns>
</mx:AdvancedDataGrid>
</s:Group>
<!-- Application.mxml -->
<?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:comp="*">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<comp:MyComponent x="272" y="86" itemsSelectionMode="singleCell"/>
</s:Application>
Erreur: valeur non valide: multipleRows. Il doit s'agir de oneRow, multipleRows, singleCell, multipleCells.
Je pense que c'est la bonne façon. Je vais l'essayer. –
Il donne toujours la même erreur. Il prend singleRow mais pas les autres. –
Et quelle est l'erreur? Avez-vous essayé le débogage? –