1 Reply Latest reply on Feb 22, 2010 4:07 PM by Flex harUI

    Issue with alert.show

    JohnMerlino

      Hey all,

       

      I have a DataGrid which is fed xml through an httpservice. When the user clicks on one of rows in the DataGrid, I would like to display more information about that specific record. But the problem is when I click on an item in a row, absolutely nothing happens. Here's what I have used:

       

              <![CDATA[
                 
                  import mx.core.IFlexDisplayObject;
                  import mx.managers.PopUpManager;
                  import mx.controls.dataGridClasses.DataGridItemRenderer;
                  import mx.events.ListEvent;
                  import mx.controls.Alert;

       

                 
                  [Bindable]
                  private var user_requests:XML;
                  private const CONTEXT_URL:String = "http://localhost:3000";
                 
                  public function init():void
                  {
       
                      this.user_requestsGrid.addEventListener(ListEvent.ITEM_CLICK, itemClicked);
                  }
                 
                  private function itemClicked(le:ListEvent):void
                  {
                     
       
                      var itemContents:XML = this.user_requestsGrid.selectedItem as XML;
                     

                      var detailContents:XMLList = itemContents.user_request;
                     

                      var colInd:int = le.columnIndex;

                     
                      var value:String = detailContents.children()[colInd];   
           
                     
                      if (value != null)
                      {
                          Alert.show(value, "user_request");
                      }
                     
                  }

       

                 
              ]]>
             
          </fx:Script>

       

          <fx:Declarations>
              <mx:HTTPService id="user_requestsIndex" url="{CONTEXT_URL}/user_requests.xml"
                              resultFormat = "e4x"
                              result="user_requests=event.result as XML"/>
             
              <mx:HTTPService id="user_requestsCreate" url="{CONTEXT_URL}/user_requests.xml"
                              method = "POST"
                              resultFormat="e4x"
                              contentType="application/xml"
                              result="user_requestsIndex.send()"/>
             
              <mx:HTTPService id="user_requestsUpdate" url="{CONTEXT_URL}/user_requests/{user_requestsGrid.selectedItem.id}/confirm_request"
                              method="POST"
                              resultFormat = "e4x"
                              contentType="application/xml"
                              headers="{{X_HTTP_METHOD_OVERRIDE: 'PUT'}}" />
             
          </fx:Declarations>

       

      <mx:Panel>
              <mx:DataGrid  id="user_requestsGrid"     
                            dataProvider="{user_requests.user_request}"
                            editable="true">
                 
                  <mx:columns>
                      <mx:DataGridColumn headerText="User Request" dataField="id" editable="true"/>
                      <mx:DataGridColumn  headerText="Status" dataField="user_request_status_id" editable="true"/>
                  </mx:columns>
              </mx:DataGrid>

       

          </mx:Panel>

         
      </s:Application>  

       

      Any suggestions? All I am trying to do is when a user clicks on a row (which corresponds to a record), a pop up is invoked which shows all the subset of data for that specific record:

      <user_requests type="array">

      <user_request>
      <created_at type="datetime">2010-02-22T19:49:41Z</created_at>
      <user_request_status>request_submitted</user_request_status>
      <updated_at type="datetime">2010-02-22T19:49:41Z</updated_at>
      </user_request>
      </user_requests>

       

      Thanks for any response.