1 Reply Latest reply on Sep 28, 2010 2:58 PM by Pat Moody

    Flex 4 Advanced DataGrid Refresh with database record changes at server end

    Pat Moody Level 1

      I've visited a number of posts regarding this problem and none of the solutions presented seem to fix the issue I'm having. I'm beginning to think it is a bug with the DataManagement functions in Flex.

       

      In my application I have followed the example presented on the Flex 4 tutorials:

      "Using data management to synchronize server updates".

      http://help.adobe.com/en_US/Flex/4.0/FlexTutorials/WSbde04e3d3e6474c4292a0331216558354b-80 00.html#WSbde04e3d3e6474c4-211e6e7c12846356a0c-8000

       

      I've tried with both client-side and server-side typing with the same issue.

       

      I'm using Flex 4 with ColdFusion 9 connecting to an MSSQL 2008 database. The table I'm working with uses a GUID as the identifyer (I have also tried with unique numeric types too).

       

      The application is running fine besides one issue. I am using the myService.commit(); control to do a bulk update to rows that have been added to the DataGrid. At the database end I am inserting values into some fields that are not determined at the client end. The database is updating fine, so the commit seems to be doing that part of the work. However, there does not seem to be any way of reflecting those new values provided at the ColdFusion CFC insert within the DataGrid. I've tried re-assigning the DataGrid to the dataProvider / different dataProvider after the commit. Refreshing the DataGrid using myDataGrid.dataProvider.refresh() seems to partly work. i.e. The Grid is refreshed with the records it held before I added any + the first row of the new inserts. The missing rows are only visible if I do not refresh at all (without their server side changes) or if I reload the entire page.

       

      Any help would be greatly appreciated.

      Cheers

      Pat

       

      PS. If I add further rows to the DataGrid and then commit a subsequent time then it refreshes with the rows that were missing on the previous commit and the first row of the latest commit.

       

      Message was edited by: Pat Moody

        • 1. Re: Flex 4 Advanced DataGrid Refresh with database record changes at server end
          Pat Moody Level 1

          My solution when adding new values at the server end is to modify the  createEmployee in the CFC to something like this. In this example I'm  using modified_date as the additional field maintained at the server  end. This could be any number of additional fields.
          Basically it's  doing an insert and then a select. Tried returning as array / Employee  but couldn't get that to work so using the query object return type of  "any". Using this method, no refresh is required on the DataGrid.


          <cffunction name="createEmployee" output="false" access="remote" returntype="any" > 
               <cfargument name="item" type="Employee" required="true" /> 
           
                   <cfquery name="qCreateEmplyee" datasource="fb_tutorial_db" result="result"> 
                       INSERT INTO employees (first_name, last_name, gender, birth_date, hire_date, modified_date ) 
                       VALUES (<CFQUERYPARAM cfsqltype="CF_SQL_VARCHAR" VALUE="#item.fname#">, 
                               <CFQUERYPARAM cfsqltype="CF_SQL_VARCHAR" VALUE="#item.lname#">, 
                               <CFQUERYPARAM cfsqltype="CF_SQL_VARCHAR" VALUE="#item.gender#">, 
                               <CFQUERYPARAM cfsqltype="CF_SQL_DATE" VALUE="#item.bdate#">, 
                               <CFQUERYPARAM cfsqltype="CF_SQL_DATE" VALUE="#item.hdate#">,
                               <CFQUERYPARAM cfsqltype="CF_SQL_TIMESTAMP" VALUE="#now()#">) 
                   </cfquery> 
           
                   <cfset var qItem=""> 
                   <cfquery name="qItem" datasource="fb_tutorial_db"> 
                     SELECT 
                     #result.GENERATED_KEY# as emp_id
                     ,first_name as fname
                     ,last_name as lname
                     ,gender
                     ,birth_date as bdate
                     ,hire_date as hdate
                     ,modified_date as mdate 
                     FROM employees 
                     WHERE emp_no = <CFQUERYPARAM CFSQLTYPE="CF_SQL_INTEGER" VALUE="#result.GENERATED_KEY#"> 
                   </cfquery> 
                   
                <cfreturn qItem>                         
          </cffunction>