4 Replies Latest reply on Apr 1, 2009 11:20 AM by Newsgroup_User

    Change ItemRendere Properties in DATAGRID

    Pratap Reddy Level 1
      Hi,

      I created a DATAGRID with some Itemrenderers in it.

      I am trying to change the properties of itemrendere on rollOver of DATAGRID.

      code:

      Code:

      <mx:DataGrid id="dataGrid" dataProvider="{targetProfiles}" itemRollOver="onItemRollOver(event)" itemRollOut="hideMenu(event)">
      <mx:columns>
      <mx:DataGridColumn id="nameCol" dataField="Name"
      headerText="Name" itemRenderer="components.itemrenderer.labelName">
      </mx:DataGridColumn>
      <mx:DataGridColumn id="description"
      dataField="Description"
      headerText="Description" />
      </mx:DataGrid>

      code for ITem Renderer

      Code:

      <?xml version="1.0"?>
      <!-- dpcontrols/adg/myComponents/ChartRenderer.mxml -->
      <mx:VBox height="65" width="100%" xmlns:mx=" http://www.adobe.com/2006/mxml" verticalAlign="middle">

      <mx:HBox paddingLeft="20" paddingTop="5" verticalAlign="bottom">
      <mx:Label text="{data.Name}"/>
      </mx:HBox>

      <mx:HBox horizontalAlign="right" verticalAlign="bottom">
      <mx:Button id="options" text="Options" visible="false"/>
      </mx:HBox>

      </mx:VBox>

      Now what am trying to do is.. On rollOver and rollOut of particular row in datagrid i want to make that Button in Itemrender visible true/false(on selected row).

      Any idea how to identify the itemRenderer on rollOver of grid????

      Thanks & Regards
      Pratap
        • 1. Re: Change ItemRendere Properties in DATAGRID
          Peter Hahmann
          I'll look for a better method to do it, but meanwhile you can do it so:

          At your itemrenderer code, add a function to cretioncomplete event.
          In this function add a eventlistener to your outerDocument, in this case your datagrid. outerDocument.addEventListener(....)

          Guess this will solve your problem.

          Regards,
          peter
          • 2. Re: Change ItemRendere Properties in DATAGRID
            Pratap Reddy Level 1
            Hi Peter,
            Thanks for reply,
            i tried as u said, but its displaying that button in all rows on datagrid.
            I want button to be displayed only in selected row.
            i.e., if i rollOver on a row.. only in that row i want button to be visible..

            Thanks & Regards
            Pratap
            • 3. Re: Change ItemRendere Properties in DATAGRID
              Peter Hahmann Level 1
              Hm... i see...

              I'm sorry but I wont be able to give you an answer now. Sorry!

              Regards,
              peter
              • 4. Re: Change ItemRendere Properties in DATAGRID
                Level 7

                "Pratap Reddy" <webforumsuser@macromedia.com> wrote in message
                news:gqvp63$68$1@forums.macromedia.com...
                > Hi Peter,
                > Thanks for reply,
                > i tried as u said, but its displaying that button in all rows on datagrid.
                > I want button to be displayed only in selected row.
                > i.e., if i rollOver on a row.. only in that row i want button to be
                > visible..
                >

                If you add another property to your data object that is just for the
                rollover/rollout, you should be able to set that property on the item to
                true or false, then bind the visibility of the button to that property:

                onItemRollOverHandler(e:event):void {
                renderer:UIComponent = e.currentTarget as UIComponent;
                dataObject:YourDataObjectType = renderer.data as YourDataObjectType;
                dataObject.IsRolledOver=true;
                }

                HTH;

                Amy