IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Flex Discussion :

La DataProvider est modifié, mais le DataGrid ne change pas.


Sujet :

Flex

  1. #1
    Membre régulier
    Profil pro
    Développeur informatique
    Inscrit en
    Mars 2008
    Messages
    80
    Détails du profil
    Informations personnelles :
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2008
    Messages : 80
    Points : 114
    Points
    114
    Par défaut La DataProvider est modifié, mais le DataGrid ne change pas.
    Bonjour à tous,

    Je souhaite insérer dans un "DataGrid" une colonne qui contient des boutons. Et je souhaite qu'une pression sur un bouton modifie des valeurs affichées dans le "DataGrid" (sur la ligne sur laquelle est positionné le bouton).

    Le "DataProvider" est lié au "DataGrid" ([Bindable]). Donc toute modification d'une valeur du DataProvider devrait se répercuter sur le DataGrid. Il n'en est rien. Il semble qu'il faille faire quelque chose qui ressemble à:

    event.currentTarget.dataProvider.itemUpdated(event.itemRenderer.data);

    J'ai utilisé la ligne ci-dessus pour résoudre un autre problème : Valider les valeurs entrées via l'éditeur d'item par défaut du DataGrid.

    Cela dit, avec le bouton, je ne parviens pas à me dépatouiller. J'ai essayé beaucoup de choses, mais je suis bloqué. Voici le code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
     
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application   xmlns:mx="http://www.adobe.com/2006/mxml"
                xmlns:custom="componants.*"
                horizontalAlign="center"
                verticalAlign="middle">
     
     
       <mx:Script>
          <![CDATA[
             import mx.collections.ArrayCollection;
     
             [Bindable]
             public var provider:ArrayCollection = new ArrayCollection([
             {Nom:'Dupont', Prenom:'Bernard', Age:10, Tel:'0123456789'},
             {Nom:'Dupont', Prenom:'Alain',   Age:20, Tel:'9876543210'},
             {Nom:'Durand', Prenom:'Fabien',  Age:30, Tel:'7410852963'}]);
          ]]>
       </mx:Script>
     
       <mx:Box>
          <mx:DataGrid id="IdDataGridMain" editable="true" dataProvider="{provider}" variableRowHeight="true" resizableColumns="true" wordWrap="true">
             <mx:columns>
                <mx:DataGridColumn dataField="Nom"    headerText="Nom abonné"/>
                <mx:DataGridColumn dataField="Prenom" headerText="Prénom abonné"/>
                <mx:DataGridColumn dataField="Age"    headerText="Age" resizable="true" itemEditor="componants.EmailEditor" editorDataField="value"/>
                <mx:DataGridColumn dataField="Tel"    headerText="Téléphone"/>
     
                <mx:DataGridColumn editable="false">
                   <mx:itemRenderer>
                      <mx:Component>
                            <mx:Button label="RAS" click="RAS(event)">
                               <mx:Script>
                                  <![CDATA[
                                     import flash.events.Event;
                                     public function RAS(event:Event):void
                                     {
                                        data.Tel = "0000000000";
                                     }
                                  ]]>
                               </mx:Script>
                            </mx:Button>
                      </mx:Component>
                   </mx:itemRenderer>
                </mx:DataGridColumn>
     
             </mx:columns>
          </mx:DataGrid>
       </mx:Box>
     
    </mx:Application>

    Quand je presse un bouton "RAS", le "DataProvider" est modifié. Le numéro de téléphone associé est mis à zéro. Mais ce changement n'est pas répercuté sur le "DataGrid".

    Si, après avoir pressé le bouton, vous modifiez une cellule dans la colonne "Age", alors les changements sont visibles. Donc je pense qu'il faut envoyer un évènement... Mais comment?

    Qui pourrait m'aider?

    Merci beaucoup,

    Denis

  2. #2
    Membre régulier
    Profil pro
    Développeur informatique
    Inscrit en
    Mars 2008
    Messages
    80
    Détails du profil
    Informations personnelles :
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2008
    Messages : 80
    Points : 114
    Points
    114
    Par défaut
    J'ai finalement trouvé!

    The <mx:Component> tag defines a new scope within an MXML file, where the local scope of the item renderer or item editor is defined by the MXML code block delimited by the <mx:Component> and </mx:Component> tags. To access elements outside of the local scope of the item renderer or item editor, you prefix the element name with the outerDocument keyword.


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
     
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application   xmlns:mx="http://www.adobe.com/2006/mxml"
                xmlns:custom="componants.*"
                horizontalAlign="center"
                verticalAlign="middle">
     
     
       <mx:Script>
          <![CDATA[
             import mx.collections.ArrayCollection;
     
             [Bindable]
             public var provider:ArrayCollection = new ArrayCollection([
             {Nom:'Dupont', Prenom:'Bernard', Age:10, Tel:'0123456789'},
             {Nom:'Dupont', Prenom:'Alain',   Age:20, Tel:'9876543210'},
             {Nom:'Durand', Prenom:'Fabien',  Age:30, Tel:'7410852963'}]);
     
          ]]>
       </mx:Script>
     
       <mx:Box>
          <mx:DataGrid id="IdDataGridMain" editable="true" dataProvider="{provider}" variableRowHeight="true" resizableColumns="true" wordWrap="true">
             <mx:columns>
                <mx:DataGridColumn dataField="Nom"    headerText="Nom abonné"/>
                <mx:DataGridColumn dataField="Prenom" headerText="Prénom abonné"/>
                <mx:DataGridColumn dataField="Age"    headerText="Age" resizable="true"/>
                <mx:DataGridColumn dataField="Tel"    headerText="Téléphone"/>
     
                <mx:DataGridColumn editable="false">
                   <mx:itemRenderer>
                      <mx:Component>
                            <mx:Button label="RAS" click="RAS(event)">
                               <mx:Script>
                                  <![CDATA[
                                     import flash.events.Event;
                                     public var app:Object;
                                     public function RAS(event:Event):void
                                     {
                                        data.Tel = "0000000000";
    									outerDocument.IdDataGridMain.dataProvider.refresh();
    								}
                                  ]]>
                               </mx:Script>
                            </mx:Button>
                      </mx:Component>
                   </mx:itemRenderer>
                </mx:DataGridColumn>
     
             </mx:columns>
          </mx:DataGrid>
       </mx:Box>
     
    </mx:Application>
    A+

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Lien à modifier : mais où est-il ?
    Par Najaxvitres dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 04/02/2010, 19h11
  2. Réponses: 6
    Dernier message: 21/10/2009, 18h39
  3. Réponses: 4
    Dernier message: 04/06/2006, 15h35
  4. XHTML / CSS : c'est super mais pourquoi?
    Par G.D.O dans le forum Mise en page CSS
    Réponses: 12
    Dernier message: 07/03/2006, 15h08
  5. Comment savoir qu'un fichier est modifie
    Par moniphal dans le forum Langage
    Réponses: 2
    Dernier message: 02/10/2005, 11h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo