2 Replies Latest reply on Oct 19, 2007 11:50 AM by WebmastaDj

    Simple Problem...

    WebmastaDj
      Ok, here is the problem I am having. I am trying to use a datagrid and when an user clicks on an entry it takes them to another "state" where it desplays more information. The problem I have is that it happens whenever a user clicks on the chart column headers (you know, when they are trying to sort them). Is there any way I can stop this from happening. Only opening the other state when a data entry is clicked just not anywhere in the datagrid. Here is the code I am currently using.

      <mx:DataGrid x="0" y="0" width="347" height="323" id="dgTopics" dataProvider="{forumTopicRequest.lastResult.data.key}" click="forumMessageRequest.send(),currentState='ViewMessages'">
      <mx:columns>
      <mx:DataGridColumn headerText="Subject" dataField="SUBJECT"/>
      <mx:DataGridColumn headerText="User" dataField="USER"/>
      </mx:columns>
      </mx:DataGrid>
        • 1. Re: Simple Problem...
          atta707 Level 2
          Sure.

          1) try to use itemClick instead of click event as it gives you rowIndex
          2) move your itemClick event to method of it's own. e.g. itemClick="showDetail(event)"
          3) in your showDetail method check that rowIndex > 0 before you switch states

          That's it.

          You might find this article helpful:
          http://www.adobe.com/devnet/flex/articles/graduating_pt1.html

          HTH,


          ATTA
          • 2. Re: Simple Problem...
            WebmastaDj Level 1
            Ok, I was able to figure it out. I needed to use the doubleclick. Now when the sort the data (with a single click) it sorts the data without opening the ViewMessages state. Now, the user can doubleclick on an entry and it still do what it needs to do.

            Here is the new code:
            <mx:DataGrid x="0" y="0" width="347" height="323" id="dgTopics" dataProvider="{forumTopicRequest.lastResult.data.key}" doubleClick="forumMessageRequest.send(),currentState='ViewMessages'" doubleClickEnabled="true">
            <mx:columns>
            <mx:DataGridColumn headerText="Subject" dataField="SUBJECT"/>
            <mx:DataGridColumn headerText="User" dataField="USER"/>
            </mx:columns>
            </mx:DataGrid>