10 Replies Latest reply on Dec 12, 2008 8:38 AM by Newsgroup_User

    Prevent Dragging AdvancedDataGrid Column before Navigation Column

    ericbelair Level 1
      Is there any way to prevent the user from dragging and dropping an AdvancedDataGridColumn to the location before the Navigation column? I don't remember this functionality being allowed in Flex 3 Beta versions. And, now I can't find a way to prevent the drop.

      What AdvancedDataGridEvent is triggered when the user begins dragging a column? "headerDragOutside" appears to only be triggered if the column is begin dragged outside a "group" of columns. and "headerShift" only triggers after the user has released the mouse button and the item is dropped. If I could figure this out, then I could probably write ActionScript to prevent the drop.

      Any help would be greatly appreciated.

      Thank you.
        • 1. Prevent Dragging AdvancedDataGrid Column before Navigation Column
          Sreenivas R Adobe Employee
          Earlier to Beta 3 we didn't hear requests for making other columns as navigation column (other than the first column). When we started hearing such requests, we added a new property called treeColumn to allow for this. And hence the restriction to drop a column before the navigation column was removed.

          You can implement the functionality by overriding the columnDraggingMouseUpHandler in a derived class of ADG and check if dropColumnIndex is the navigation column and skip calling the super method.
          • 2. Re: Prevent Dragging AdvancedDataGrid Column before Navigation Column
            ericbelair Level 1
            Thanks Sreenivas!

            Will something like this work?

            package components
            {
            import flash.events.MouseEvent;

            import mx.controls.AdvancedDataGrid;

            public class CustomADG extends AdvancedDataGrid
            {
            public function CustomADG()
            {
            super();
            }

            override protected function columnDraggingMouseUpHandler(event:MouseEvent):void
            {
            if (dropColumnIndex == 0)
            {
            return;
            }
            }
            }
            }
            • 3. Re: Prevent Dragging AdvancedDataGrid Column before Navigation Column
              ericbelair Level 1
              I feel like I'm getting closer - I really am just starting to grasp the basic concepts of OOP, though I've been programming in Flex/AS for about 7 months now.

              Performing a "return" in my override function stops the drop from occurring, however, it just hangs there. How do I... "rewind" or "cancel" the drag action?
              • 4. Re: Prevent Dragging AdvancedDataGrid Column before Navigation Column
                ericbelair Level 1
                Ok. I've got it working, but I'm sure my code is not the best:

                package components
                {
                import flash.events.MouseEvent;

                import mx.controls.AdvancedDataGrid;
                import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
                import mx.controls.advancedDataGridClasses.AdvancedDataGridHeaderInfo;
                import mx.core.mx_internal;

                use namespace mx_internal;

                public class CustomADG extends AdvancedDataGrid
                {
                public function CustomADG()
                {
                super();
                }

                override protected function columnDraggingMouseUpHandler(event:MouseEvent):void
                {
                var headerInfo:AdvancedDataGridHeaderInfo = getHeaderInfo(movingColumn);

                var origIndex:int = headerInfo.index;//movingColumn.colNum;

                if (dropColumnIndex == 0)
                {
                dropColumnIndex = headerInfo.index;
                }

                super.columnDraggingMouseUpHandler(event);
                }

                override mx_internal function getHeaderInfo(col:AdvancedDataGridColumn):AdvancedDataGridHeaderInfo
                {
                if(columnGrouping)
                return columnsToInfo[itemToUID(col)];
                else
                return super.getHeaderInfo(col);
                }

                }
                }

                Is there anyway to access the mx_internal getHeaderInfo() function without copying and pasting the exact same code from the AdvancedDataGrid class?
                • 5. Re: Prevent Dragging AdvancedDataGrid Column before Navigation Column
                  ericbelair Level 1
                  This is broken now. I just tried to compile my app, and I was given this compilation error:

                  Severity and Description Path Resource Location Creation Time Id
                  1023: Incompatible override. line 39 1229020574929 32684

                  Does anyone have any suggestions? Is there some other to accomplish this?
                  • 6. Re: Prevent Dragging AdvancedDataGrid Column before Navigation Column
                    Level 7

                    "ericbelair" <webforumsuser@macromedia.com> wrote in message
                    news:ghrngt$ri9$1@forums.macromedia.com...
                    > This is broken now. I just tried to compile my app, and I was given this
                    > compilation error:
                    >
                    > Severity and Description Path Resource Location Creation Time Id
                    > 1023: Incompatible override. line 39 1229020574929 32684

                    Usually that means you didn't match the original method signature, which
                    could mean wrong number of arguments, wrong type of arguments, or wrong
                    return type.

                    HTH;

                    Amy


                    • 7. Re: Prevent Dragging AdvancedDataGrid Column before Navigation Column
                      ericbelair Level 1
                      Well, i thought that might be the case. Unfortunately, this "open source" software does not provide access to the source code of data visualization items. Fun.

                      I guess this method went away with the new SDK??? Because it is no longer listed in the documentation.

                      Oh well.

                      If anyone has any suggestions on how to prevent users from dropping columns to a column index before the navigation column, I would really appreciate it.

                      Thanks.
                      • 8. Re: Prevent Dragging AdvancedDataGrid Column before Navigation Column
                        Level 7

                        "ericbelair" <webforumsuser@macromedia.com> wrote in message
                        news:ghrqi6$251$1@forums.macromedia.com...
                        > Well, i thought that might be the case. Unfortunately, this "open source"
                        > software does not provide access to the source code of data visualization
                        > items. Fun.
                        >
                        > I guess this method went away with the new SDK??? Because it is no longer
                        > listed in the documentation.
                        >
                        > Oh well.
                        >
                        > If anyone has any suggestions on how to prevent users from dropping
                        > columns to
                        > a column index before the navigation column, I would really appreciate it.
                        >
                        > Thanks.

                        http://blogs.adobe.com/flexdoc/2008/04/extracting_data_visualization.html


                        • 9. Prevent Dragging AdvancedDataGrid Column before Navigation Column
                          ericbelair Level 1
                          Thanks Amy. Those instructions didn't work for me, but it pointed in the right direction.... I found this page:

                          http://www.hemtalreja.com/?p=3

                          ...which had easier, and working instructions. I got the code extracted, and it turns out the compilation error was thrown because SDK 3.0 had the "event" parameter as a MouseEvent, and SDK 3.2 has is as simply "Event" (flash.events.Event).

                          Still doesn't explain why this protected function is not in the documentation....
                          • 10. Re: Prevent Dragging AdvancedDataGrid Column before Navigation Column
                            Level 7

                            "ericbelair" <webforumsuser@macromedia.com> wrote in message
                            news:ghttj3$nd5$1@forums.macromedia.com...
                            > Thanks Amy. Those instructions didn't work for me, but it pointed in the
                            > right
                            > direction.... I found this page:
                            >
                            > http://www.hemtalreja.com/?p=3http://www.hemtalreja.com/?p=3
                            >
                            > ...which had easier, and working instructions. I got the code extracted,
                            > and
                            > it turns out the compilation error was thrown because SDK 3.0 had the
                            > "event"
                            > parameter as a MouseEvent, and SDK 3.2 has is as simply "Event"
                            > (flash.events.Event).
                            >
                            > Still doesn't explain why this protected function is not in the
                            > documentation....

                            Not sure. There's a lot of stuff like that where the documentation falls
                            short. The most probably explanation is that they didn't write ASDOC
                            comments or they used one of the notations that exclude the function from
                            the automatic generation
                            ( http://livedocs.adobe.com/flex/3/html/help.html?content=asdoc_6.html),
                            because they didn't "think" developers would need to override this function.