25 Replies Latest reply on Jun 11, 2010 11:04 AM by anxious33

    How to link data to a datagrid ?




      I'm following flex tutorials but i'm not doing exactly as they do, so  :


      What i want

      I have an input text, with a button 'search'.

      I want when this button is clicked that the data returned by  the function search are displayed in the datagrid.


      What i have :


      The text input :


      <s:TextInput includeIn="DetailServeurs" x="58" y="361" width="209" id="txt_search" text="Default text" focusIn="txt_search_focusInHandler(event)"/>


      a Search button :


      <s:Button includeIn="DetailServeurs" x="275" y="361" label="Rechercher" id="btn_rechercher" click="btn_rechercher_clickHandler(event)"/>


      a clickhandler for this search button  :


      protected function btn_rechercher_clickHandler(event:MouseEvent):void
      if(txt_search.text != ""){
      .token = serveurService.getServeurByName(txt_search.text);

      and a datagrid :


      <mx:DataGrid includeIn="DetailServeurs" x="30" y="124" width="1002" height="179" id="dataGrid" dataProvider="{getServeurByNameResult.lastResult}">
      <mx:DataGridColumn headerText="GSP_nom" dataField="GSP_nom"/>
      <mx:DataGridColumn headerText="port" dataField="port"/>

      So how can i display the results in the datagrid ? Thanks !