0 Replies Latest reply on Oct 9, 2009 6:47 AM by WiseAdobe

    Please Help: Array From CFC To Flex Advanced Data Grid: I AM STUCK!!!

    WiseAdobe

      I could use some help/clarification.

       

      Currently using Flex with SDK 3.4 with a MSSQL database using Coldfusion 7MX.

       

      What I am trying to do is return an array from a stored procedure via a CFC to an advanced data grid.

       

      The array should look as follows:

       

      [Bindable]
      private var budgetData:Array = [
          { Task: "TaskA", budgethours:42.8, bugetrate:351,
              children:[
                  {Title: "Manager", budgethours:26.0, budgetrate:446,
                      children:[
                          {Name: "Smith, Joe", budgethours:0, budgetrate:0},
                          {Name: "Young, Jane", budgethours:0, budgetrate:0}
                      ]},
                  {Title: "Associate", budgethours:26.0, budgetrate:289}
              ]}
          }],

       

      When I bind this array to the advanced data grid in Flex everything works fine.   

       

      <mx:AdvancedDataGrid id="billed"
              folderClosedIcon="{null}"
              folderOpenIcon="{null}"
              defaultLeafIcon="{null}">
              <mx:dataProvider>
                  <mx:HierarchicalData source="{budgetData}"/>
              </mx:dataProvider>
              <mx:columns>
              <mx:AdvancedDataGridColumn headerText="Hours" dataField="budgethours" width="120" />
              <mx:AdvancedDataGridColumn headerText="Rate" dataField="budgetrate" width="150" />
              </mx:columns>
      </mx:AdvancedDataGrid>

       

      I am having trouble getting the adg to populate from a CFC.

       

      From what I gather I need to create an Array of Structs from the stored procedure call within the CFC and return the result as an array to Flex. In Flex I turn the array into a Bindable array collection and feed to the adg. Is this correct? I attempted this with a simple array without any children using the CFC logic below and the adg was empty but did contain a blank row for every record my stored procedure returned. This leads me to believe that Flex is getting some information regarding the data but it can't render it somewhow. Debugging shows null for the returned array.

       

      CFC:

       

          <cffunction name="getBudgetData" output="false" access="remote" returntype="array">

       

              <cfstoredproc procedure="dbo.sp_Flex_Budget_GetData"
                  datasource="mydatasrouce"
                  returncode="No">

       

                  <cfprocresult name="spBudgetData">

       

              </cfstoredproc>

       

              <cfset budgetDetailArray=arraynew(2)>

       

              <cfloop query="spBudgetData">
                  <cfset budgetDetailArray[CurrentRow][1]=BudgetHours>
                  <cfset budgetDetailArray[CurrentRow][2]=BudgetRate>

       

              </cfloop>

       

              <cfreturn budgetDetailArray>

       

          </cffunction>

       

      Any help is much appreciated as I have been stuck on this for a few days now.