5 Replies Latest reply on Aug 17, 2009 10:11 PM by crissy84

    Possible to skip certain datagrid cells during keyboard navigation?

    crissy84

      Hello,

      I have some data entry forms based on a datagrid.  The users typically use keyboard navigation (tab, enter, etc) when filling out the data in the cells.  Depending on various criteria, some cells may not need to be filled in.   I don't want to competely disable them... only them make them skipped in the keyboard navigation by default.

       

      In other words, I would like to render these 'disabled' fields with a silver background (no problem here) and I want them to be skipped when navigating by keyboard.  However, I want them to be able to enter data into those fields if they specifically click on it with the mouse (essentially an override).

       

      Make sense?  This sounds like an unusual and potentially difficult requirement to implement.  Hoping someone else here can tell me how easy it will be

       

      Any suggestions on if this is feasible and maybe some pointers?

       

      Thanks!

        • 1. Re: Possible to skip certain datagrid cells during keyboard navigation?
          leybniz Level 4

          you can temporary set column.editable = false; during attempt to edit grayed cell in that particular column and revert editable state back to original one once leave the column.

           

          OR

           

          simply override createItemEditor of the adg and decide there create editor or not

           

            override public function createItemEditor(colIndex:int, rowIndex:int):void {
             super.createItemEditor(colIndex, rowIndex);
            }

          1 person found this helpful
          • 2. Re: Possible to skip certain datagrid cells during keyboard navigation?
            Gregory Lafrance Level 6

            Tab order

            You can use the tabIndex property of every component to create a tab order that determines the order in which objects receive input focus when a user presses the Tab key.


            This page discusses accessibility, but the sample code is still valid for you.

             

            http://livedocs.adobe.com/flex/3/html/help.html?content=accessible_6.html

             

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

            1 person found this helpful
            • 3. Re: Possible to skip certain datagrid cells during keyboard navigation?
              crissy84 Level 1

              Thanks for the help guys!  Sorry it took me so long to back around to this. I do appreciate your help, I just got sidetracked with some other things for a while.  I did figure out a solution a bit different from what you guys suggested.  They might've work, but maybe were just over my head.. I couldn't get those to work.

              Your suggestions...
              • "you can temporary set column.editable = false; during attempt to edit grayed cell in that particular column and revert editable state back to original one once leave the column." - I probably didn't make this clear, but they will mostly be navigating vertically... using the [ENTER] key to go down rows in a single column.  If I understand you right, it sounds like this solution is for when navigating horizontally across columns.
              • "simply override createItemEditor of the adg and decide there create editor or not" - This seemed like a great idea.  But unfortunately, not creating the editor resulted in a null pointer exception.  This led me to look at the datagrid source code.. and found that what I really need to be doing is overriding findNextEnterItemRenderer().  However, as it seems all useful functions in the Flex source are marked as private (WHY!?!?)... again stymied by a private method.
              • "You can use the tabIndex property of every component to create a tab order that determines the order in which objects receive input focus when a user presses the Tab key." - TabIndex on itemrenderer and itemeditor didn't seem to have any effect in a datagrid.

               

               

              So my solution... capture focusIn on the itemeditor.  If it's not supposed to be there, then get the rowIndex from the grid.editedItemPosition, add 1 to the row (or subtract if shift is held down) and set the new editedItemPosition.  I also have to keep track if the focus was initiated by a key or mouse click.  If it's a mouse click, then I allow it to stay on the 'disabled' cell, etc.

               

               

              • 4. Re: Possible to skip certain datagrid cells during keyboard navigation?
                Flex harUI Adobe Employee

                For regular DG, you are supposed to call preventDefault on ITEM_EDIT_BEGINNING and set editedItemPosition to a new cell position.  I think that works for ADG but I could be wrong.

                 

                Alex Harui

                Flex SDK Developer

                Adobe Systems Inc.

                Blog: http://blogs.adobe.com/aharui

                • 5. Re: Possible to skip certain datagrid cells during keyboard navigation?
                  crissy84 Level 1

                  Ah yes, I forgot about that event.  That is much cleaner than what I had. 

                  A couple notes... it does work for ADG, but I had to use ITEM_EDIT_BEGIN instead of ITEM_EDIT_BEGINNING, because when using ITEM_EDIT_BEGINNING, setting the editedItemPosition had no effect.

                  Thanks!