11 Replies Latest reply on Aug 18, 2010 11:28 AM by ssardar

    Advanced Data Grid in Action Script

    ssardar Level 1

      ok so I am now generating an AdvancedDataGrid in Action script as I will have dynamically created columns based on specific user

       

       

      My grid code looks like this

       

       

       

      private function generateGrid():void

      {

       

       

      var clms:Array;

       

      myADG.dataProvider=gridData;

      myADG.width=

      this.parentApplication.adgPanel.width-20;

      myADG.height=

      this.parentApplication.adgPanel.height-39;

      myADG.visible=

      true;

      myADG.x=0;

      myADG.y=0;

      myADG.designViewDataType=

      "flat";

      myADG.horizontalScrollPolicy=

      "on";

      myADG.verticalScrollPolicy=

      "on";

      myADG.lockedColumnCount=6;

      myADG.sortExpertMode=

      true;

      myADG.headerWordWrap=

      true;

       

       

       

      }

       

       

      My question is this, in my MXML Grid that preceded this I hand this line

       

      click="{populateChildren(adg.selectedIndex)}"

       

       

       

      How do I add this functionality to my new AS Advanced Data Grid??

       

      populateChildren is a function that allows me to set the specific row as an object and share amongst other other modules based on the grid selection.

       

              private function populateChildren(loc:int):void
              {    
                selected = Object(gridData.getItemAt(loc));
                this.parentApplication.populateChart(selected);
              }

       

       

      Thanks in advance for any help.

       

        • 1. Re: Advanced Data Grid in Action Script
          ssardar Level 1

          Column generation works fine, so I have not included this code yet, I have a follow up question about applying the DateFormatter to the field value, but one at a time

           

          • 2. Re: Advanced Data Grid in Action Script
            rahuls9009

            ok so i think u want to add the buttonclick event handler to the advancedDataGrid in AS..

            so assuming other things are right and u have a button..

             

            mybut.addEventListener(MouseEvent.CLICK,populateChildren(adg.selectedIndex));

             

            but i can see that ur populateChildren method is getting the object by using index..

            u can use the adg.selectedItem to get the Object directly and pass it around..

             

            Hope this helps..

            1 person found this helpful
            • 3. Re: Advanced Data Grid in Action Script
              ssardar Level 1

              I actually read up on this and figured this is what I needed to do last night.

               

               

              except I believe I should be able to add to the grid directly no? as opposed to a button?  The functionality from the mxml version was based on clicking on a row on the grid.

               

              myADG.addEventListener(MouseEvent.CLICK,populateChildren());

               

               

              I've changed this function to look like this:

               

              private function populateChildren(): void

              {

              selected = Object(gridData.getItemAt(myADG.selectedIndex));

               

              this.parentApplication.populateChart(selected);

              }

               

               

              but I am geting this error, not really sure I have this correctly

               

              1067: Implicit coercion of a value of type void to an unrelated type Function.

               

               

              Any Ideas?

              • 4. Re: Advanced Data Grid in Action Script
                VRPDeveloper Level 3

                getItemAt itself returns object then why are you again casting it to object... That is why you are getting that error

                 

                Remove it and then try ...it will work... Also specify what is "Selected" variable of....datatye and all


                If this post answers your question or helps, please kindly mark it as such.

                1 person found this helpful
                • 5. Re: Advanced Data Grid in Action Script
                  ssardar Level 1

                  My web service returns objectProxies so whenever I pulled from the ListCollectionView I casted to Object in order to access it.

                  But I see you're right I don't need to cast here, so I have removed it, but still getting the

                   

                   

                  1067: Implicit coercion of a value of type void to an unrelated type Function

                   

                   

                  which is puzzling...

                  • 6. Re: Advanced Data Grid in Action Script
                    VRPDeveloper Level 3

                    specify what is "Selected" variable of....datatye and all

                    • 7. Re: Advanced Data Grid in Action Script
                      ssardar Level 1

                      Sorry I left this out as I declared it at the top of my code but "selected"  (if you meant my variable)

                       

                       

                       

                      private var selected:Object = new Object;

                      • 8. Re: Advanced Data Grid in Action Script
                        VRPDeveloper Level 3

                        could u plz comment this.parentapplication.populatchart(selected) and see...

                         

                        Just see whether selected variable is populated with selected value of datagrid or not... and also let me know at which line is this error coming ..I mean at which part of code is getting error.

                        • 9. Re: Advanced Data Grid in Action Script
                          ssardar Level 1

                          I don't believe it even gets that far.  I did comment it, and the line causing the error is this one

                           

                           

                           

                          myADG.addEventListener(MouseEvent.CLICK,populateChildren());

                          • 10. Re: Advanced Data Grid in Action Script
                            VRPDeveloper Level 3

                            could you give me complete sample code of it so that I can figure out....


                            • 11. Re: Advanced Data Grid in Action Script
                              ssardar Level 1

                              The complete sample code contains 5 WebService calls that populate List collections views.

                              Given these services are not exposed externally, I can't see how that would be more helpful it would actually cause more errors.

                               

                              But as usual with being new to Flex and AS I have found the root of the problem....ME     it's always something so silly and easily overlooked.

                               

                               

                              myADG.addEventListener(MouseEvent.CLICK,populateChildren());

                               

                              should read:

                               

                              myADG.addEventListener(MouseEvent.CLICK,populateChildren);

                               

                               

                               

                              and for completeness my function needed to look like this

                               

                               

                               

                              private function populateChildren(e:Event): void

                              {

                              selected = Object(gridData.getItemAt(myADG.selectedIndex));

                               

                              this.parentApplication.populateChart(selected);

                              }

                               

                              completely back to operational again.

                               

                               

                               

                              Thanks for taking the time to look into this a bit, sorry for the trouble, but at least I will recognize that error, I had never seen it up till now.

                              Thanks again.