7 Replies Latest reply on Feb 23, 2011 9:07 AM by eprevot123

    Spark DataGrid Issue

    jfillman

      I'm working with the new Spark DataGrid, and I understand it's still a work in progress. I've also created a bug in the Adobe bug system. However, I want to be sure that I'm not overlooking something.

       

      Here is an example that illustrates the issue. If I create an itemRenderer for a column in a dDtaGrid, it takes 2 clicks to trigger the click event and 3 clicks to trigger the doubleClick event, if you click on the column with the itemRenderer. This happens about 95% of the time. Occasionally, it works as expected, but that's a rarity. So the question is, am I doing something wrong in the use of itemRenderers.

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application

       

       

      xmlns:fx="http://ns.adobe.com/mxml/2009"

      xmlns:s="

      library://ns.adobe.com/flex/spark"

      xmlns:mx="

      library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

       

       

      <fx:Declarations>

       

       

      <!-- Place non-visual elements (e.g., services, value objects) here -->

       

       

      </fx:Declarations>

       

       

      <fx:Script>

      <![CDATA[

       

       

      import mx.controls.Alert;

       

      ]]>

       

      </fx:Script>

       

       

      <s:DataGrid x="33" y="57" requestedRowCount="4" textAlign="center" click="Alert.show('Clicked')">

       

       

      <s:columns>

       

       

      <s:ArrayList>

       

       

      <s:GridColumn dataField="dataField1" headerText="Name" width="75">

       

      <s:itemRenderer>

       

      <fx:Component>

       

      <s:GridItemRenderer>

       

      <s:Label text="{data.dataField1}" left="5" paddingTop="10" paddingBottom="5"/>

       

      </s:GridItemRenderer>

       

      </fx:Component>

       

      </s:itemRenderer>

       

      </s:GridColumn>

       

      <s:GridColumn dataField="dataField2" headerText="Column2" width="75"/>

       

      <s:GridColumn dataField="dataField3" headerText="Column3" width="75"/>

       

      </s:ArrayList>

       

      </s:columns>

       

      <s:ArrayList>

       

      <fx:Object dataField1="John" dataField2="data1" dataField3="data1"></fx:Object>

       

      <fx:Object dataField1="Ryan" dataField2="data2" dataField3="data2"></fx:Object>

       

      <fx:Object dataField1="Kyle" dataField2="data3" dataField3="data3"></fx:Object>

       

      <fx:Object dataField1="Edward" dataField2="data4" dataField3="data4"></fx:Object>

       

      </s:ArrayList>

       

      </s:DataGrid>

      </s:Application>

        • 1. Re: Spark DataGrid Issue
          kevinklin Adobe Employee

          Hi,

           

          Try listening for the gridClick event instead. Thanks for filing the bug.

           

          -Kevin

          • 2. Re: Spark DataGrid Issue
            jfillman Level 1

            Kevin,

             

            I did try the gridClick event, but the issue persists. What I have found is this is an issue if the GridItemRenderer has a label component in it. The grid click and double click events work just fine if I have an image or a button in the GridItemRenderer. I haven't tried other components.

             

            JF

            • 3. Re: Spark DataGrid Issue with doubleClick
              eprevot123 Level 2

              I have approximately the same problem : I want to listen double click (doubleClick or gridDoubleClick) on a spark datagrid.

              The double click event is always dispatched when I double-click on a column whose item renderer is a textArea (even with doubleClickEnabled=false).

              The double click event is SOMETIMES dispatched when I double-click on a column whose item renderer is an image or a label :

              1. When I double-click for the first time on the label renderer : it gives focus to datagrid and select item but does not dispatch doubleClick

              2. When I double-click on the textArea colum, then on the Label column of the same row, doubleClick is well dispatched

              3. When I double-click on the textArea colum, then on the Label column of a different row, doubleClick is not dispatched

              4. when I double-click on the label column after double-clicking on another row in the Label column, doubleClick is well dispatched

               

              I think it's the same behaviour with simple click event.

              Do you think spark datagrid is not stable enough and we should use mx datagrid instead ?

               

              Here is the code :

              <s:DataGrid dataProvider="{arrayCollection}" doubleClickEnabled="true" doubleClick="trace(event)" gridDoubleClick="trace(event)">
                      <s:columns>
                          <s:ArrayList>
                              <s:GridColumn>
                                  <s:itemRenderer>
                                      <fx:Component>
                                          <s:GridItemRenderer>
                                              <s:Label text="{data.label}"/>
                                          </s:GridItemRenderer>
                                      </fx:Component>
                                  </s:itemRenderer>
                              </s:GridColumn>
                              <s:GridColumn>
                                  <s:itemRenderer>
                                      <fx:Component>
                                          <s:GridItemRenderer>
                                              <s:TextArea text="{data.label}"/>
                                          </s:GridItemRenderer>
                                      </fx:Component>
                                  </s:itemRenderer>
                              </s:GridColumn>
                          </s:ArrayList>
                      </s:columns>
                  </s:DataGrid>

              • 4. Re: Spark DataGrid Issue
                Jorge Raimundo Level 2

                Hi.

                 

                As a workarround for the single click you could probably use the selectionChange event. This one has been working fine for me.

                 

                Regards,

                Jorge

                • 5. Re: Spark DataGrid Issue
                  eprevot123 Level 2

                  Yeah for some cases this could work but :

                  - I want the double click...

                  - if you use selectionChange then when you change the selection with arow keys, the event is fired but you didn't click on an item

                   

                  My workaround is to create a custom GridItemRenderer that enables and listen doubleClick and dispatch it to the DataGrid :

                   

                  private function dispatchDoubleClickEvent(event:MouseEvent):void
                              {
                                  var gridEvent:GridEvent = new GridEvent(GridEvent.GRID_DOUBLE_CLICK);

                                  // I only need the item property in my case, but you might copy other MouseEvent properties to GridEvent
                                  gridEvent.item = event.currentTarget.data;
                                  dispatchEvent(gridEvent);
                              }

                  • 6. Re: Spark DataGrid Issue
                    kevinklin Adobe Employee

                    These are bugs that have been recently fixed. See http://bugs.adobe.com/jira/browse/SDK-29385 and http://bugs.adobe.com/jira/browse/SDK-29471.

                     

                    -Kevin

                    • 7. Re: Spark DataGrid Issue
                      eprevot123 Level 2

                      On Adobe website I just found 4.5.0.19786 and reproduced the bugs with this version.

                      Do you know where I can find the sdk version where these bugs are fixed ? or it is not released yet.