3 Replies Latest reply on Dec 18, 2011 4:09 AM by MkayGarg

    Flex 3 advanced data grid grouping, show info with tree

    flashharry! Level 1
      Sorry for strange title, some times hard to sum up in one sentence.

      I have a database with annotations (notes) on a proof. Each note as a unique id, when a note is created we capture the user and the text. The note creator can later go back and edit the note. We capture the edit and store that as well. So we have a history of all the edits to a note in the database.

      When I retrieve the I order by the time stamp so the notes are returned latest first as an array collection in php.

      I serialize this into jason, one in flex 3, I de-serialize and create a new grouping collection and sort these on the note id

      This works, I end up with an advanced data grid with folders(tree) for each note, open the folders(tree) and each note is displayed. Great so far love it.

      However (you knew it was coming), the folder name is the noteID for the database, I would like to show the first row/occurrence/latest note however you want to call it as a row with all columns correctly display, and then 'if' the user wants to see the edit history of the note they can turn down the folders, others wise work as a normal data grid.

      Any ideas...

      <AdvancedDataGrid width="100%" height="100%" id="proofCommentsGrid" dataProvider="{icsProofComments.getItemAt(0)}"/>

      private function proofCommentsHandler(event:ResultEvent):void {
      //local net connect for air desktop debugger
      if (deBuggerRunning) {
      conn.send("_debugger", "lcHandler", "Returned Data from comments fetch, processing");
      //remove event listener as I use the same http service else where
      //get the raw JSON data and cast to String
      var rawData:String = String(event.result);

      if (deBuggerRunning) {
      conn.send("_tracer", "lcHandler", "Raw JSON\n" + rawData + "\n\n" +
      "Now processing JSON to ArrayCollection TO Group for comments\n");
      //decode the data to ActionScript using the JSON API
      //in this case, the JSON data is a serialize Array of Objects.
      var arr:Array = (JSON.decode(rawData) as Array);
      acProofComments = new ArrayCollection(arr);//convert array to array collection defined else where.
      makeDataHeaders(); //function to make the data grid column headers

      //set up grouping and sort field
      var noteGroup:Grouping = new Grouping();
      var noteFieldGroup:GroupingField = new GroupingField("noteid");
      noteGroup.fields = [noteFieldGroup];

      //set up group collection
      var noteGroupColl:GroupingCollection = new GroupingCollection();
      noteGroupColl.source = proofCommentsGrid.dataProvider;//get the bound dataprovider
      noteGroupColl.grouping = noteGroup;//set the group for sorting
      noteGroupColl.refresh();//now sort

      proofCommentsGrid.dataProvider = noteGroupColl;//change dataprovider
      proofCommentsGrid.validateNow(); make sure display is updated.


        • 1. Re: Flex 3 advanced data grid grouping, show info with tree
          flashharry! Level 1
          Getting some where, any help?
          but returns NaN
          //create new grouping class
          var noteGroup:Grouping = new Grouping();
          //create new grouping field based on note id
          var noteFieldGroup:GroupingField = new GroupingField("noteid");
          //assigne grouping fileds to grouping
          noteGroup.fields = [noteFieldGroup];

          //create a note summary
          var noteSummary:SummaryRow = new SummaryRow();
          //create an object func for the summary
          //This function tells ADG to add a summary row in addition to the existing data
          noteSummary.summaryObjectFunction = objFunc;

          //create summary field
          var noteSummField:SummaryField = new SummaryField("Comments");
          noteSummField.summaryFunction = func;
          //set the summary fields
          noteSummary.fields = [noteSummField];
          //where to place summery
          noteSummary.summaryPlacement = "group";
          noteFieldGroup.summaries = [noteSummary];

          var noteGroupColl:GroupingCollection = new GroupingCollection();
          noteGroupColl.source = proofCommentsGrid.dataProvider;
          noteGroupColl.grouping = noteGroup;


          proofCommentsGrid.dataProvider = noteGroupColl;

          private function objFunc():SummaryObject {
          var obj:SummaryObject = new SummaryObject();
          obj.summary = true;
          return obj;
          private function func(itr:IViewCursor,field:String, str:String=null):Object {
          trace(itr.current.Comments);//traces correct
          var comment:String = String(itr.current.Comments);
          return comment;

          • 2. Re: Flex 3 advanced data grid grouping, show info with tree
            flashharry! Level 1

            seems like this is limited to displaying a number, why not a string?

            I would like to show first row of the grouped data

            • 3. Re: Flex 3 advanced data grid grouping, show info with tree



              Did you get any solution for this problem. I'm also stuck with similar kind of problem, where i want to show the processed status on summary row. My Grid should look like below:


              Category                           SUM(Amount)             Resultant Status:String


                |___>Sub Class                SUM(Amount)             Resultant Status:String


                             |_____>Type     Amount:Number           Status:String



              The Status on Type level is like "Failed", "Working", "Abort", and resultant status on summary row level should be worst of all (if all working then working else failed).


              Please let me know if there is any help.