6 Replies Latest reply on Jun 14, 2011 7:05 AM by bon_t

    How to make a grid cell uneditable without messing up tabbing

    bon_t Level 1

      I'm using an AdvancedDataGrid in ActionScript 3/Flex 4. The grid has 5 columns: Caller Intent, Labels, Strategy, Confirmation Mode, and Confirmation Promptlet. All columns are editable except for Labels. However, if you change the Confirmation Mode value to NEVER, the next column Confirmation Promptlet becomes uneditable and is set with the value 'n/a' (this is the desired functionality).

       

      app_config_screen.JPG


      Unfortunately, the image is not very clear at all. I changes the Confirmation Mode value to NEVER in the second row. This is what happens when I start tabbing out of the Confirmation Mode cell:
      1st Tab: Confirmation Promptlet populated with 'n/a'. I don't see anything in focus.
      2nd Tab: The 5th tab from the left in the view stack (dark grey) is in focus.
      3rd Tab: I don't see anything in focus.
      4th Tab: The button with the green '+' (top left) is in focus. 5th Tab: The grid itself is in focus.
      6th Tab: Finally I get to the Caller Intent cell of the next row (when this image was captured)

       

      I tried setting tabEnabled="false" and tabFocusEnabled="false" for the button. I set only tabFocusEnabled="false" for the AdvancedDataGrid. But then the Tab focus starts moving to the components in the upper right panel and lower right panel.

       

      I need to accomplish 2 things:
      1. Have tabbing be contained in the grid, in the upper right panel, and in the lower right panel. Meaning tabbing should not cross from one area to another.
      2. Have an uneditable field not mess up the normal tabbing behaviour.

       

      Thank you.
      Bonnie

        • 1. Re: How to make a grid cell uneditable without messing up tabbing
          Flex harUI Adobe Employee

          Tabbing through cells is handled via ITEM_EDIT_XXX events and setting

          editedItemPosition.

          1 person found this helpful
          • 2. Re: How to make a grid cell uneditable without messing up tabbing
            bon_t Level 1

            Hi there!

             

            I'm trying to force the columnIndex and rowIndex values of my grid's editedItemPosition object with no success .

             

            Here is my code:

                                            protected function adgGrid_itemEditBegin( event:AdvancedDataGridEvent ):void {
                                                if ( clickCount <= 1 || adg_mappedTagsList.selectedItems.length > 1 ) {
                                                    event.preventDefault();
                                                } else {
                                                    // If user is trying to edit promptlet field but mode has been set to NEVER, make promptlet field non-editable.
                                                    if ( event.columnIndex == 4 && adg_mappedTagsList.selectedItem[ "confirmationMode" ] == 2 ) {
                                                        adg_mappedTagsList.editedItemPosition.columnIndex = 0;
                                                        adg_mappedTagsList.editedItemPosition.rowIndex = adg_mappedTagsList.selectedIndex + 1;
                                                        event.preventDefault();
                                                    }
                                                }                       
                                            }

             

            I stepped through the debugger and I do not see the values being changed:

            adg_mappedTagsList.editedItemPosition = Object (@a3ae8e1)
                columnIndex = 4
                rowIndex = 2
            adg_mappedTagsList.selectedIndex = 2

             

            In this scenario, the values should be 0 for columnIndex and 3 for rowIndex.  However, as I stepped over the two assignment statements, I do see the address of the editedItemPosition object being changed.

             

            What am I missing here?

            Thanks!

            Bonnie

            • 3. Re: How to make a grid cell uneditable without messing up tabbing
              Flex harUI Adobe Employee

              Set editedItemPosition to a new object with the desired properties.  In

              general, Flex/Flash APIs don't watch for changes to internal properties of

              objects and arrays used in the APIs

              • 4. Re: How to make a grid cell uneditable without messing up tabbing
                bon_t Level 1

                Hi again,

                 

                Thank you for your quick response.  This method works for me but I observed something interesting.

                 

                My new code is (and it's tied to an itemEditBegin):

                 

                                                protected function adgGrid_itemEditBegin( event:AdvancedDataGridEvent ):void {
                                                    if ( clickCount <= 1 || adg_mappedTagsList.selectedItems.length > 1 ) {
                                                        event.preventDefault();
                                                    } else {
                                                        // If user is trying to edit promptlet field but mode has been set to NEVER, make promptlet field non-editable.
                                                        if ( event.columnIndex == 4 && adg_mappedTagsList.selectedItem[ "confirmationMode" ] == 2 ) {
                                                            adg_mappedTagsList.editedItemPosition = { columnIndex:0, rowIndex:adg_mappedTagsList.selectedIndex+1 };
                                                            event.preventDefault();
                                                        }
                                                    }                       
                                                }

                 

                After stepping over the assignment statement, I still see the old values in the debugger:

                adg_mappedTagsList.editedItemPosition = Object (@b52d5f9)   
                    columnIndex = 4   
                    rowIndex = 1   
                adg_mappedTagsList.selectedIndex = 1   
                cellToEdit = Object (@ac93af1)   
                    columnIndex = 0   
                    rowIndex = 2  

                 

                However, when I returned to the GUI, the desired result was obtained!

                This is probably what you mean by "Flex/Flash APIs don't watch for changes to internal properties of objects and arrays used in the APIs".

                 

                Thansk so much for your guidance!

                Bonnie

                • 5. Re: How to make a grid cell uneditable without messing up tabbing
                  Flex harUI Adobe Employee

                  That's a subtle timing issue in DataGrid.  Technically, it is a bug.  The

                  editedItemPosition stores the value in a temporary variable and applies it

                  later.

                  • 6. Re: How to make a grid cell uneditable without messing up tabbing
                    bon_t Level 1

                    I just started using Flex last July with no formal training.  Little bugs like this can confuse a newbie

                    like me.  Again, thanks so much for your help and patience.