2 Replies Latest reply on Jan 31, 2007 10:04 PM by Like2Flex

    Query and DataGrid Problem

    Like2Flex Level 1
      Hello Flex people,

      I have a major problem with query and datagrid.

      I have a function as follows in my .cfc :

      <cffunction name="getNames" access="remote" returntype="query">
      <cfquery name="myquery" datasource="mydb">
      select #variables.my_field_list#
      from tbl_test where 1 =1

      <cfreturn myquery>


      Now in flex, i created a function as follows :

      public function getNames(event:ResultEvent):void
      names = event.result as ArrayCollection;
      grid_names.dataProvider = names;

      This function populates the grid BUT the columns are displayed in alphabetical order. Sometimes in #variables.my_field_list#, I have B,C,A,F but the columns are displayed as A,B,C,F.

      I can't use,
      <mx:Array id="cols">

      <mx:DataGridColumn headerText="B" dataField="B"/>
      <mx:DataGridColumn headerText="C" dataField="C"/>
      <mx:DataGridColumn headerText="A" dataField="A"/>
      <mx:DataGridColumn headerText="F" dataField="F"/>

      ,because #variables.my_field_list# varies in the number of fields that it can have.

      Can somebody tell me how to get the columns in the order that i want without using <mx:DataGridColumn headerText="A" dataField="A"/> and so on. It should be somthing in the function above (in flex) I suppose, but I don't know what ??

      Anyone pls, urgent help required.