4 Replies Latest reply on Sep 10, 2009 10:24 AM by Flex harUI

    Double click on Datagrid cell

    Ferrari_hunk

      Hi,

       

      I'm developing an application where I'm using a datagrid that shows some information from an xml. Every cell in the grid is of the form

      <itemRenderer>

      <compoment>

      <Vbox>

      <HBox>

      <Text/> //some text goes within this block

      <Text/> //some text goes within this block

      <Text/> //some text goes within this block

      </Hbox>

      </VBox>

      </component>

      </itemRenderer>

       

      I have set a function call for the datagrid on ItemDoubleClick event; and this even gets triggered only when i double click on any TEXT that is on the cell; and NOT on any part of the cell. However, I would like to have this triggered when the user clicks anywhere in the cell.

      Sombody please help,

       

      Thanks!!

        • 1. Re: Double click on Datagrid cell
          Flex harUI Adobe Employee

          Not sure I understand, but try setting backgroundColor="0xffffff" backgroundAlpha="0" on the HBox.

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

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

          • 2. Re: Double click on Datagrid cell
            Ferrari_hunk Level 1

            Hi,

             

            Thanks for the suggestion. Maybe I wasn't clear in explaining the issue here. Let me throw some light now, My code is somewhat like this

             

             

            <mx:VBox opaqueBackground="{myxml.@data>10 ?  '0xA2FEA2' : '0xFEA2A2' }" width="100%" height="100%" verticalScrollPolicy="off">

                 <mx:Box width="100%" height="100%">

                      <mx:Text id="txt1" text="Available" width="100%"/>

                       <mx:Text id="txt2" text="{myxml.@data}"/>

                 </mx:Box>

            </mx:VBox>

             

            The output is shown in the attachment. Now whenever I double click on the text in the datagrid(highlighted in blue in the attachment) my doubleclick even is fired; but if i click anywhere in the cell(green region in the attachment) my doubleclick event is not called.

             

            Hope this helps! Looking forward for your assistance,

            Thanks again!!

            Cheers

            • 3. Re: Double click on Datagrid cell
              Ferrari_hunk Level 1

              Hi Alex,

               

              My bad, I had not tried your solution, as I thought the background color that I was setting using the opaqueBackgroundColor(on VBox) would be lost if I set backgroundColor='0xffffff' on HBox. But this seems to have done the trick and it works fine now. I believe flex was not taking HBox to be an "item" as it was blank (even though it had Text fields within). Correct me if I'm wrong.

               

              Appreciate your help!

              Cheers!

              • 4. Re: Double click on Datagrid cell
                Flex harUI Adobe Employee

                Containers have no background by default so clicks can fall through.

                 

                Alex Harui

                Flex SDK Developer

                Adobe Systems Inc.

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