1 Reply Latest reply on May 10, 2010 12:25 AM by kubens

    How to Make DataGrid configured to act only on a Specific column only a Row

    kiran7881 Level 1
      Hi,

       

      I am having a DataGrid which has been populated with a search result data from DataBase .
      Say for example

       

      CustomerID         Name             Email

       

      100                       Ravi              ravi@gmail.com

       

       

      Now my requirement is

       

      When the user clicks on CUstomerID only i want to generate an event , but not not to any other coulmn on that particular row
      (Means for example i dont want to generate an event when he clicks on email or name in my case.)

       

      Please tell me how to implement this ??
        • 1. Re: How to Make DataGrid configured to act only on a Specific column only a Row
          kubens Level 2

          You can solve this by using a custom item renderer:

           

          mxDataGridItemRenderer_customerId.mxml:

          <?xml version="1.0" encoding="utf-8"?>
          <s:MXDataGridItemRenderer
              xmlns:fx="http://ns.adobe.com/mxml/2009"
              xmlns:s="library://ns.adobe.com/flex/spark"
              xmlns:mx="library://ns.adobe.com/flex/mx"
              focusEnabled="false"
              width="100%"
              autoLayout="true"
              autoDrawBackground="false"
          >
              <fx:Script>
                  <![CDATA[
                      import mx.controls.Alert;
                    
                      protected function mxdatagriditemrenderer_clickHandler(event:MouseEvent):void
                      {
                          Alert.show('click');
                      }
                  ]]>
              </fx:Script>
            
              <s:Label id="customerId" text="{data.customerId}" click="mxdatagriditemrenderer_clickHandler(event)"/>
          </s:MXDataGridItemRenderer>

           

          inside your data grid:

          <mx:DataGridColumn headerText="CustomerId" width="100" itemRenderer="mxDataGridItemRenderer_customerId" />

          1 person found this helpful