DataGrid Using an item renderer that spans an entire row

Anyone know how can I do this using DataGrid?

I dont understand how Can I do it. Below I have a source code that I'm working with this case. I have 2 columns and I would like when i click in combobox my item renderer fill all rows.
Look I have this code (Main Application and Renderer):
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009"
     xmlns:s="library://ns.adobe.com/flex/spark"
     xmlns:mx="library://ns.adobe.com/flex/halo">
     <mx:transitions>
          <mx:Transition fromState="*" toState="*">
               <mx:Resize target="{this}"/>
          </mx:Transition>
     </mx:transitions>
     <mx:states>
          <mx:State name="normal"/>
          <mx:State name="expanded"/>
     </mx:states>
     <fx:Script>
     <![CDATA[
          import mx.collections.ArrayCollection;
          [Bindable]
          public var ac:ArrayCollection;
          private function changeState(event:Event) : void {
               if( event.target.selected )
                    currentState = "expanded";
               else
                    currentState = "normal";
          override public function set data(value:Object) : void {
               super.data = value;
               ac = new ArrayCollection(value.models);
     ]]>
     </fx:Script>
     <mx:CheckBox label="{data.title}" click="changeState(event)"/>
     <mx:List dataProvider="{ac}" y="20" width="100%" includeIn="expanded"/>
</mx:Canvas>
<s:Application
     xmlns:fx="http://ns.adobe.com/mxml/2009"   
     xmlns:mx="library://ns.adobe.com/flex/halo"    
     xmlns:s="library://ns.adobe.com/flex/spark"
     xmlns:ct="*"
     height="100%" width="100%">
     <fx:Script>
     <![CDATA[
          import mx.collections.ArrayCollection;
          [Bindable]
          public var dp:ArrayCollection = new ArrayCollection([
          {title:"Ford", style: 'Modern', models:["Fusion","Taurus","Mustang"]},
               {title:"Volkswagen",  style: 'Normal', models:["Passat","Jetta","Beetle", "Golf", "GTI"]},
               {title:"Infiniti", style: 'Modern', models:["FX35","GX35","Q45","M35"]},
               {title:"Audi",  style: 'Esport', models:["A3","A4","A6"]}
     ]]>
     </fx:Script>   
     <mx:DataGrid dataProvider="{dp}" variableRowHeight="true" height="100%" width="100%">
          <mx:columns>
               <mx:DataGridColumn dataField="title" headerText="title" itemRenderer="DetailItem"/>
               <mx:DataGridColumn dataField="style" headerText="style" />
          </mx:columns>
     </mx:DataGrid>
</s:Application>

Similar Messages

  • Datagrid and Inline Item renderer problem

    I have a datgrid with two inline item renderers. The dataprovider for my DG is a nested object (objects within objects within objects i.e 3-layered).
    Main Object - 1st Level
                              |
                  2nd Level Object 1
                                    |
                                3rd level object '1' => ('name'=>somename,'id'=>someid)
                                3rd level object '2'
                                3rd level object 'n'
                 2nd Level Object 2
                                    |
                                3rd level object '1' => ('name'=>somename,'id'=>someid)
                                3rd level object '2'
                                3rd level object 'n'
    I use 2 item renderers (one for each datagrid column) which loops thro the 2nd level object1 and 2 respectively (the 2nd level object is a dynamic array of objects, in that the number of objects within keep changing).
    Within the item renderer I loop thro the 2nd level object using a foreach and then display the data. The data is a linkbutton, which when clicked , calls a remote object function to delete the data from the database
    now on the result event of the remote object function call, i call the function to repopulate the DG, so that the updated data is displayed.
    When i click on the linkbutton in the first row, the backend works perfectly fine (the data gets deleted from the database and the refreshed data is sent back), but for some reason, the deleted data suddenly appears in the 2nd row.
    When i delete it from the second row, it appears on the 3rd row (nothing happens in the backend since the data is already deleted).. and so on, till it appears on the last row and then the DG looks exactly the way it shld have looked after the first delete.
    This is just the beginning. The second item renderer also displays a linkbutton, which when clicked, displays that data in the previous column (the one where this data can be deleted). When i click on 1st row, the data gets added in the previous column of the second row .. and so on..
    Basically, my DG is acting really weird. I overrided the set data function in the item renderer to refrsh the data and called its invalidateDisplayList. I also call the Datagrid's invalidateDisplayList function after each refresh.  The behavior remains the same.
    Please help me on this ...

    Hi, Post a test code.... It will be a lot easier to help you Mich

  • Datagrid Drop Down Item renderer Scroll Problem

    Hi,
    I am having a problem with an drop down item renderer on a Datagrid.  When ever the datagrid is displayed and the cell is clicked on i want this to display a drop down list of objects.  I can get the drop down to appear with the list of objects.  H
     owever the scrollbar does not work on this item to allow the user to scroll through all the objects.  If you use the mouse wheel you can scroll down through them all but not when you try and click on the scroll bar to drag down.  Below is the code used.  Any advice why this might be happening?? 
    <mx:DataGridColumn headerText="Widget"
    dataField="WidgetName"
    editable="true"  headerWordWrap="false" textAlign="center" width="100"
    editorDataField="Widget">
    <mx:itemEditor>
    <fx:Component>
    <s:MXDataGridItemRenderer focusEnabled="true" height="22" >
    <fx:Script>
    <![CDATA[               
    import mx.events.FlexEvent;
    import spark.events.IndexChangeEvent;
    private var selectedWidget:Widget = null;
    public function get ccyPair():String {
    return  ddlCcyPairs.selectedItem.Widget;
    override protected function commitProperties():void {
    super.commitProperties();                
    trace("Commit .......");
    protected function ddlCcyPairs_changeHandler(event:IndexChangeEvent):void {
    for each(var ccyP:CurrencyPair in ddlCcyPairs.dataProvider) {
    if (ccyP.ccyPair == ddlCcyPairs.selectedItem.ccyPair) {
    selectedWidget = ccyP;
    ddlCcyPairs.selectedItem = selectedWidget;
    protected function ddlCcyPairs_creationCompleteHandler(event:FlexEvent):void {                 
    for each(var ccyP:CurrencyPair in ddlCcyPairs.dataProvider) {
    if (ccyP.ccyPair ==  data.ccyPairName) {
    selectedWidget = ccyP;
    ddlCcyPairs.selectedItem = selectedWidget;
    ]]>
    </fx:Script>
    <s:DropDownList id="ddlWidgets" width="100%"
    dataProvider="{parentApplication.Widgets}"
    labelField="name"              
    selectedItem="selectedWidget"
    creationComplete="ddlWidgets_creationCompleteHandler(event)"
    change="ddlWidgets_changeHandler(event)"/>
    </s:MXDataGridItemRenderer>
    </fx:Component>
    </mx:itemEditor>
    </mx:DataGridColumn>

    Hi, Post a test code.... It will be a lot easier to help you Mich

  • Programmatically selecting hovered state of item renderer - Greg pleeease

    I'm a bit new to Flex, so I have the idea but can't get it to work.
    I'm using an item renderer that takes its data from an HTTPService
        <s:SkinnableDataContainer
                                  dataProvider="{boData}"
                                  itemRenderer="extras.BoItemRenderer"
                                  skinClass="extras.BoSkin" />
    the boData data provider is an ArrayCollection not an Array
    In my <s:ItemRenderer ...... > (BoItemRenderer.mxml)  I have
    - 2 states: normal and hovered (each has different style, which I will leave out to keep things simple)
    - and the data is presented as follows:
        <s:HGroup>
            <s:Label text="{data.idNum}" />         
            <s:Label text="{data.firstName}" />
            <s:Label text="{data.lastName}" />
        </s:HGroup>
    Naturally as I hover on any row in the item renderer, it changes to the hovered state styling, all done by flex.
    What I want to do however is programmatically induce that hover state without actually hovering.
    For example, given a hard-coded idNum, I need to programmatically set the state of that row to hovered.
    My approach is as follows, but not sure how to target that specific item,
    - search the dataProvider to find the index of the row with idNum that matches my hard-coded value. I looked at the documentation, and there is indexOf, but it's for Array and not ArrayCollection.. also not sure how that works since I'd like to read the data from the item renderer directly, not from the original data provider.
    - then I would find that index in the itemrenderer and set the state of that index to hovered.
    Simpler said then done, but I'm stuck on it...
    Thanks,
    David

    Depending on what is it the ArrayCollection, in theory you might be able to do this:
    var myIndex:uint;
    for(var a:uint=0;a<myCollection.length;a++){
        if(myCollection.getItemAt(a).idNum == myHardCodedIdNum){
            myIndex = a;
            break;
    You can programmatically simulate a hover over by having the component manually dispatch a mouseOver event, but this is not the way to do it with itemRenderers.
    Item renderers can be tricky, particularly if they are being used in List based controls, like List, DataGrid, TileList, etc. because the itemRenderers are recycled.
    With that in mind, and with your somewhat non-typical situation (manually simulating hover over), I might be wrong on this, but it might be best to control this via the dataProvider data. So have a field named currState, and somehow make the renderer automatically change its state if that data field changes, then you simply programmatically change the currState data field for the desired item.
    As far as how to change the state of the item renderer based on changes to a data field, maybe ChangeWatcher?
    If this post answers your question or helps, please mark it as such.
    Greg Lafrance - Flex 2 and 3 ACE certified
    www.ChikaraDev.com
    Flex / AIR Development, Training, and Support Services

  • How to dispatch custom events from an item renderer used for Datagrid Column

    Hi,
    I am using an Item Renderer for a Data Grid Column and in that mxml, I am dispatching a custom event with data.
    But the main mxml which has the DataGrid is not able to resolve the event. How can I solve this?
    Thanks

    Hi,
    This is the constructor for Event.
    public function Event(type:String, bubbles:Boolean  = false, cancelable:Boolean  = false)
    When you created your custom event after extending from Event, for the parent container receives the event, the bubbles property must be set to true.
    Please check if you have done so. That should solve the problem. Let me know if it doesn't.
    Nishad

  • Item Renderer in a Datagrid

    I'm struggling with how to make a check mark ( image ) show
    up or not based on the value of some data in each datagrid line
    item. I'm using an item renderer but I'm missing something. Any
    help would be greatly appreciated.
    thanks,
    STeveR

    The following is my entire itemrenderer...please excuse any
    bad style as this is a WIProgress..
    Its probably easier to quote the adobe docs on listdata...If
    a component implements the IDropInListItemRenderer interface, you
    can use its listData property to obtain information about the data
    passed to the component when you use the component in an item
    renderer or item editor..I made sure the component implements the
    interface as you can see in the code at the top of component. Then
    add the couple of required functions regarding listdata, then you
    can access the listdata in your own functions in the renderer, like
    i do in set data function.
    this.BTN_***_mark.label =
    value[DataGridListData(listData).dataField];
    this line assigns the value from my datagrid to the renderers
    button label. (this renderer is a button that the user can press)
    so i want the buttons label to show the value coming in from the
    datagrid. So listdata is just a way to
    explicitly get the column name where the current data is
    being sourced from in your datagrid.As the grid is being rendered,
    it renders row by row. In each row it goes thru your columns . SO
    initially it for row 1 it would begin rendering firstname, surname,
    mark, average...etc etc. If i put an alert in on
    value[DataGridListData(listData).dataField
    I would see these column names popping up as they are getting
    rendered in the DGrid.
    Hope this helps...
    <!-- <?xml version="1.0" encoding="utf-8"?>-->
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    creationComplete="init()" width="74" height="30"
    horizontalAlign="center" verticalAlign="middle"
    implements="mx.core.IFactory,mx.controls.listClasses.IDropInListItemRenderer">
    <mx:Metadata>
    </mx:Metadata>
    <mx:Script>
    <![CDATA[
    import mx.managers.PopUpManager;
    import mx.controls.DataGrid;
    import mx.utils.ArrayUtil;
    import mx.collections.ArrayCollection;
    import mx.collections.IViewCursor;
    import mx.controls.Alert;
    import mx.events.*;
    import mx.controls.dataGridClasses.DataGridListData;
    import mx.controls.listClasses.BaseListData;
    import mx.controls.dataGridClasses.DataGridColumn;
    import mx.containers.TitleWindow;
    private var panel:AssessmentMarkPopup = new
    AssessmentMarkPopup();
    var the_val = 0;
    var col_index:int;
    private var _listData:BaseListData;
    public function get listData() : BaseListData
    return _listData;
    public function set listData( value:BaseListData ) : void
    _listData = value;
    private function showLoginForm():void {
    var pop:AssessmentMarkPopup =
    AssessmentMarkPopup(PopUpManager.createPopUp(this,AssessmentMarkPopup,true));
    pop.addEventListener("closepopup",onClose);
    pop.TXT_***_mark.text = this.BTN_***_mark.label;
    var row:int =
    this.parentApplication.DG_class_students.selectedIndex;
    pop.student_name =
    this.parentApplication.DG_class_students.selectedItem.firstname + "
    " + this.parentApplication.DG_class_students.selectedItem.lastname;
    private function onClose(e:MyClosePopupEvent):void{
    this.BTN_***_mark.label = e.data.mark;
    public function newInstance():*
    return new MarkEntry();
    public override function get data():Object
    return super.data;
    override public function set data(value:Object):void {
    var dg:DataGrid = (listData) ? DataGrid(listData.owner) :
    null;
    var column:DataGridColumn = (dg) ?
    dg.columns[listData.columnIndex] as DataGridColumn : null;
    col_index = listData.columnIndex;
    var str:String = String(column.dataField);
    this.BTN_***_mark.label =
    value[DataGridListData(listData).dataField];
    ]]>
    </mx:Script>
    <mx:Button click="showLoginForm()" id="BTN_***_mark"
    width="52"/>
    </mx:VBox>

  • Item renderer on DataGrid (not DataGridColumn)

    It seems that all the published examples of using an item renderer on a DataGrid use the itemRenderer property of DataGridColumn.
    I don't think I can do this because my columns are created at run time, depending on the contents of the data provider.
    I have therefore tried to assign my item renderer (a subclass of Canvas) directly to the DataGrid.
    1. This works in MXML when the renderer is inline.
    2. It sees to work when the renderer is an Actionscript class assigned to the DataGrid's itemRenderer property.
    3. It does NOT work when the renderer is Flex component assigned to the DataGrid's itemRenderer property. This compiler error is reported: Initializer for 'itemRenderer': cannot parse value of type mx.core.IFactory from text 'comp:CellRenderer'.
    I prefer to use the last method. Is there a way to fix this error?
    If not, is it possible to attach the item renderer to each DataGridColumn as it is created? DataGrid does not seem to have a suitable event that reports when a column is created.
    Aplogies if this is elementary stuff. I am a real Flex newbie. I am using Flex Builder 3.0
    Andy Kirkham

    A code example would be helpful here, but from your error message it
    looks like you may be doing the following
    <mx:DataGrid itemRenderer="comp:CellRenderer"/>
    Instead of  this, you need to use the fully qualified class name of
    CellRenderer, eg.
    com.renderers.CellRenderer
    Look at the definition of 'comp' towards the top of your MXML file, it
    will be something like:
    xmlns:comp="blah.blah.blah.*"
    Your itemRenderer property should then be set to:
    blah.blah.blah.CellRenderer

  • Datagrid item renderer delete button

    I have a datagrid with an item renderer. In the item renderer
    is a delete button img. Onclick it will remove the item from the
    datagrid with the exception of the first item. I am using outer
    document to call my function but when I do I get an error that says
    Attempt access of inaccessible method deleteContact through a
    reference with static type myTitleWindowContact?
    private function deleteContact(event:Event,data:*):void{
    if (contactData.selectedIndex >= 1) {
    caseVO.acCont.removeItemAt(contactData.selectedIndex);
    <mx:DataGrid dataProvider="{model.currentVO.acCont}"
    id="contactData"
    width="651"
    height="117"
    click="showForm()" >
    <mx:columns>
    <mx:DataGridColumn editable="false" width="5">
    <mx:itemRenderer>
    <mx:Component>
    <mx:HBox width="100%" height="15"
    horizontalAlign="center" verticalAlign="middle">
    <mx:Button
    icon="@Embed(source='/com/serg/reportingTool/assets/images/delete.png')"
    click="outerDocument.deleteContact(event,data)"
    label="D"
    toolTip="Delete"
    width="15"
    height="15"
    />
    </mx:HBox>
    </mx:Component>
    </mx:itemRenderer>
    </mx:DataGridColumn>

    That fixed that issue Thanks so much! One other question
    though. Is it possible to have my delete button appear on all items
    in the datagrid except for the first item??

  • Inbuilt Item Rendering inside DataGrid .

    Hi ,
    Please find the screen shot attached with this Thread .
    The data is been populated into the Datagrid from DataBase using ArrayCollection as DataProvider .
    Now i want to have Radio Buttons displayed at the begning of the each row of Names Column .
    When i tried to use , inbuilt itemRenderer as mx.controls.RadioButton ,  inside DataGridColumn  of 'Names' Column of DataGrid   , the Data appeared in such a way that all the Data inside the Names Column is repalced by showing only RadioButtons .
    Please tell me if this is possible using Inbuilt Item Rendering itself??(As Custom Rendering seems tough for me rigjt now )
    Or suggest me an easy approach , basically my requirement  is that i want to get the Selected Value Object into a function for doing Upadate and Delete facility .
    Please help
    Thanks in advance .

    Thanks for the reply , sorry for th
    late reply as i dont have Flex at my Work place .
    This is my code :
                <mx:DataGrid  id="MyDG" height="100%" width="100%"
                     dataProvider="{flightList}" change="GetTheValue()">
                <mx:columns>
                    <mx:DataGridColumn headerText="Names" dataField="uname">
            <mx:itemRenderer>
    mx.controls.RadioButton
    </mx:itemRenderer>
                    </mx:DataGridColumn>
    <mx:DataGridColumn headerText="Pwds" dataField="pass" >
                    </mx:DataGridColumn>
                </mx:columns>
                            </mx:DataGrid>
    This is the screen shot earlier and now afeter adding Item Rendering , Any help .
    Please find the screen shots attached

  • Datagrid item renderer numberstepper tabIndex

    I have a datagrid with a item renderer in it that contains a
    numberStepper. There are two columns that have number steppers in
    them. If I hit tab when I am in the first number stepper I want it
    to tab to the second one. I have tried setting a tabIndex and I
    can't get it to tab? Any thoughts?

    Here is my Scenario, in my datagrid the second column of the first row (987.93) background color depends upon some condtion. The remaning rows of column B depends upon the column C . If "the column C is OK" it will be green , "NOT OK" red. But the first row's second column color depends upon some other condition. How can i achieve this ?

  • DataGrid Item Renderer loading duplicates after scroll

    HI,
    I have a report that loads into a datagrid, these reports are
    about thumbnail images that are on a server.
    I have a datagrid item renderer that loads the thumb nails.
    When the grid first loads the first set of rows that are visible
    display the correct images. But after I scroll the new rows have
    images that are repeated and not the correct ones.
    ?xml version="1.0" encoding="utf-8"?>
    <HBox xmlns="
    http://www.adobe.com/2006/mxml"
    horizontalScrollPolicy="off" verticalScrollPolicy="off"
    creationComplete="{init()}">
    <Script>
    <![CDATA[
    import mx.controls.Image;
    [Bindable]
    [Embed(source="/images/folderBlack.png")]
    private var folderIcon:Class;
    private function suffix(url:String):String {
    var i:Number;
    if ((i = url.lastIndexOf(".")) > -1) {
    url = url.substr(i+1);
    return url;
    private function init():void {
    var fileSuffix:String = new String;
    fileSuffix = '';
    fileSuffix = suffix(data.filename);
    var staticPortalImage:String = new String;
    staticPortalImage = '/PULLIMAGE.php?type=small&id=' +
    data.FileID +
    '&path=' + data.filename +
    '&server=MTI3LjAuMC4x&siteurl=L0F1dGhNb2R1bGU=';
    var thumbNailImage:Image = new Image();
    thumbNailImage.height = 80;
    switch(fileSuffix){
    case 'jpg':
    thumbNailImage.source = staticPortalImage;
    break;
    imageContainer.addChild(thumbNailImage);
    texttest.text = fileSuffix;
    ]]>
    </Script>
    <Text id="texttest" />
    <HBox id="imageContainer" height="80" />
    </HBox>

    Thanks
    Great article I ended up getting rid of the creationcomplete
    changing my init():void too override public function set data(
    value:Object ) : void
    and adding
    super.data = value;
    I was able then to clean up my code considerably.
    Once again Thanks
    Dean

  • Two item renderer for one datagrid column?

    hi
    i have one doubt
    can we use two item renderer for one datagrid column
    any possibilities
    why i am asking this because
    during drag and drop i need one itemrenderer and during application initialization i need another itemrenderer
    any possibilities
    karthik.k

    Hi,
    I think your requirement can be completed by using ViewStack you can pass selected index to it according to requirement.
    See:
    <itemRenederer ...
         <viewstack selectedIndex = 0 ...>
              <vBox id="vBox1" >
                        Your 1st itemrenderer will come here....
              </vBox>
              <vBox id="vBox2" >
                        Your 2nd itemrenderer will come here....
              </vBox>
         </viewStack>
    </itemRenederer>
    You have to just toggle selectedIndex.
    Thanks

  • How to change the background color of a cell in datagrid using flex3

    i want to change the background color of a cell.....how can i achieve this.....and also i want to know how a spacing cane be done between cells in a datagrid...plzzz help me???

    The only way I can see to do this is to use an item renderer for your cells.  This is really scruffy and would need tyding up, and maybe with a little more time could do better or someone else may have an idea but none the less this works.
    Define a custom component as below;
    This has logic to see what the value of the data is proveided by the dataprovider for the row, and if it matches the conditions in this case is equal to 5 sets the background color.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="88" height="26" dataChange="doColor()" borderColor="#000000" borderStyle="solid"
        backgroundAlpha="1">
        <mx:Script>
            <![CDATA[
                private function doColor():void {
                    if (data.value == 5) {
                        setStyle('backgroundColor', 0xcccccc);
                    } else {
                        setStyle('backgroundColor', 0xffffff);
            ]]>
        </mx:Script>
    </mx:Canvas>
    Now just apply the item renderer in the datagrid and that will do it.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"  xmlns:ns1="*">
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                [Bindable]
                private var ac:ArrayCollection = new ArrayCollection([
                    {value : 1},
                    {value : 2},
                    {value : 3},
                    {value : 4},
                    {value : 5},
                    {value : 6},
                    {value : 7},
                    {value : 8},
                    {value : 9},
                    {value : 10}
          ]]>
        </mx:Script>
        <mx:DataGrid x="40" y="36" width="408" height="193" dataProvider="{ac}">
            <mx:columns>
                <mx:DataGridColumn headerText="Column 1" dataField="value" itemRenderer="MyComp"/>
                <mx:DataGridColumn headerText="Column 2" dataField="col2"/>
                <mx:DataGridColumn headerText="Column 3" dataField="col3"/>
            </mx:columns>
        </mx:DataGrid>
    </mx:Application>
    I hope this helps
    Andrew

  • How to access item renderer from main mxml?

    Hi,
    I have a datagrid which has item renderer. Code looks like this:
    <mx:DataGrid id="newsfeedgrid" width="100%" height="100%" visible="true" verticalScrollPolicy="auto"
                                  verticalGridLines="false" horizontalGridLines="true" horizontalGridLineColor="#E5F0F3" showHeaders="false"
                                  rowHeight="70" wordWrap="true" resizableColumns="false">
                                  <mx:columns>
                                            <mx:DataGridColumn headerText="Image Name" dataField="imgname" width="100">
                                            <mx:itemRenderer>
                                                      <mx:Component>
                                                                <mx:VBox height="100%" width="100%">
                                                                <!--          <mx:Image source="{data.imgname}" height="100%" width="100%"/>-->
                                                                <local:SmoothImage source="{'http://localhost/musicbook/attachdoc/'+data.imgname}" height="100%" width="100%"/>
                                                                          <mx:Text text="{data.fname+' '+data.lname}" fontSize="10" fontWeight="bold" fontFamily="Verdana" color="#3D3636"/>
                                                                </mx:VBox>
                                                      </mx:Component>
                                            </mx:itemRenderer>
                                            </mx:DataGridColumn>
                                            <mx:DataGridColumn headerText="Messages" dataField="mymsg" wordWrap="true" resizable="true"
                                                      >
                                                      <mx:itemRenderer>
                                                                <mx:Component>
                                                                          <mx:VBox verticalScrollPolicy="off" creationComplete="lbl_initialize()">
                                                                                    <!--<mx:HBox width="100%">
                                                                                              <mx:Text text="{data.uname}" width="100%" color="BLUE" fontSize="10" fontWeight="bold"
                                                                                              useHandCursor="true" buttonMode="true" mouseChildren="false"
                                                                                              click="this.outerDocument.userPage('msgFromC onnGrid')"/>
                                                                                              <mx:Text text="{data.actmsg}" width="100%" fontSize="10" fontWeight="bold"
                                                                                              />
                                                                                              <mx:Text text="{data.secuname}" width="100%" color="BLUE" fontSize="10" fontWeight="bold"
                                                                                              useHandCursor="true" buttonMode="true" mouseChildren="false"
                                                                                              click="this.outerDocument.userPage('msgFromC onnGrid')"/>
                                                                                    </mx:HBox>-->
                                                                                    <mx:Text id="lbl" width="100%"
                                                                            selectable="true"
                                                                            link="lbl_link(event);" />
                                                                                    <!--<mx:ControlBar id="cbar">-->
                                                                                    <mx:Spacer height="50%"/>
                                                                                    <mx:HBox width="100%">
                                                                                    <mx:Text text="{data.datetime}" fontSize="7" color="#8B9698"/>
                                                                          </mx:HBox>
                                                                           <mx:Script>
                                                                        <![CDATA[
                                                                            import mx.controls.Alert;
                                                                                    public var tempsecuname:String;
                                                                            private function lbl_initialize():void {
                                                                                      /* if(lbl.text=="Pratik is good")
                                                                                                lbl.htmlText="<a href='event:flex.org'>Good</a> is Pratik";
                                                                               //lbl.htmlText = "For more information on Flex, see <u><a href='event:flex.org'>http://www.flex.org/</a></u>.";
                                                                                if(data.secuname==null)
                                                                                          tempsecuname = "";
                                                                                else
                                                                                          tempsecuname=data.secuname;
                                                                               lbl.htmlText="<a href='event:flex.org'><font color='#2112EF'><b>"+data.uname+"</b></font></a>"+data.actmsg+"<a href='event:flex.org'><font color='#2112EF'><b>"+tempsecuname+"</b></font></a>";            
                                                                            private function lbl_link(evt:TextEvent):void {
                                                                                Alert.show(evt.toString(), evt.text);
                                                                                switch (evt.text) {
                                                                                    case "flex.org":
                                                                                        // You clicked the flex.org link.
                                                                                        break;
                                                                        ]]>
                                                                    </mx:Script>
                                                                          </mx:VBox>
                                                                </mx:Component>
                                                      </mx:itemRenderer>
                                            </mx:DataGridColumn>
                                  </mx:columns>
                                            </mx:DataGrid>
    Problem currently is since lbl_initialize() function is called on creationComplete of Vbox, output displayed is not expected and when ever i navigate to grid page output gets changed and it is not proper.
    I wanted to use text ,lbl, in my main.mxml so that i can assign the value when i am setting data provider.
    Please help!!!

    Thanks for your reply.. overriding set data in fact is a better approach and my half problem is solved but i am still facing some issues. Please find my code below:
    <mx:DataGridColumn headerText="Messages" dataField="mymsg" wordWrap="true" resizable="true"
                                                      >
                                                      <mx:itemRenderer>
                                                                <mx:Component>
                                                                          <mx:VBox verticalScrollPolicy="off" >
                                                                                    <mx:Text id="lbl" width="100%"
                                                                            selectable="true"
                                                                            link="lbl_link(event);" />
                                                                                    <!--<mx:ControlBar id="cbar">-->
                                                                                    <mx:Spacer height="50%"/>
                                                                                    <mx:HBox width="100%">
                                                                                    <mx:Text text="{data.datetime}" fontSize="7" color="#8B9698"/>
                                                                          </mx:HBox>
                                                                           <mx:Script>
                                                                        <![CDATA[
                                                                                  import mx.core.Application;
                                                                            import mx.controls.Alert;
                                                                                    public var tempsecuname:String;
                                                                                    public var tempmsg:String="";
                                                                                   override public function set data( value:Object ) : void {
                                                        super.data = value;
                                                                               lbl.htmlText="<a href='event:data.uname'><font color='#2112EF'><b>"+data.uname+"</b></font></a>"+tempmsg;
                                                                               if(data.datetime>Application.application.lastlogout)
                                                                                         Alert.show(Application.application.lastlogout);
                                                                                         lbl.setStyle("fontWeight","bold");
                                                                            private function lbl_link(evt:TextEvent):void {
                                                                        ]]>
                                                                    </mx:Script>
                                                                          </mx:VBox>
                                                                </mx:Component>
                                                      </mx:itemRenderer>
                                            </mx:DataGridColumn>
    Now my text is coming properly with link like how i wanted. I have added here another functionality where I am checking the last logouttime of user and the msg time and if msgtime is greater than last logout time then i am showing it in bold.
    override public function set data( value:Object ) : void {
                                    super.data = value;
                    lbl.htmlText="<a href='event:data.uname'><font color='#2112EF'><b>"+data.uname+"</b></font></a>"+tempmsg;
                    if(data.datetime>Application.application.lastlogout)
                    Alert.show(Application.application.lastlogout);
                    lbl.setStyle("fontWeight","bold");
    First time is shows properly but if i scroll then some random row is also appearing in bold, also when ever this set data function is getting called some random rows are coming in bold.
    Please let me know your input

  • Item Rendering component

    In my datagrid I used Inline item rendering to create text link. code is given
    <mx:DataGridColumn headerText="Nomenclature">
                <mx:itemRenderer>
                     <mx:Component>
                          <mx:Label htmlText="&lt;u&gt;{data.NOMENCLATURE}&lt;/u&gt;" color="blue" click="newBrowserWindow(data.CALL_URL);" >
                          <mx:Script>
                          <![CDATA[
                               private function newBrowserWindow(url:String):void{
                                  var urlRequest:URLRequest = new URLRequest(url);
                                  navigateToURL(urlRequest,"_blank");
                          ]]>
                          </mx:Script>
                          </mx:Label>           
                     </mx:Component>           
                </mx:itemRenderer>
    </mx:DataGridColumn>
    I have to replicate this functionality in multiple datagrids in  multiple applications, I am trying to create component for it and use that component in datagrid column. How can i do this?

    I have achieved this. but my issue is
    if someother datagrid has field data.EMPLOYEE_NAME instead of data.NOMENCLATURE, then how can i achive this. the component should be reuseable for any other datagrid having different field names.
    <mx:DataGridColumn headerText="Nomenclature">
                <mx:itemRenderer>
                     <mx:Component>
                          <mx:Label  >
                          <mx:Script>
                          <![CDATA[
                               override public function set data(value:Object):void
                                   super.data = value;
                                    if (value.hasOwnProperty("NOMENCLATURE"))
                                       // your code here like add click listener.
                                  else if (value.hasOwnProperty("EMPLOYEE_NAME"))
                                           // your code here like showing the employee name etc
                          ]]>
                          </mx:Script>
                          </mx:Label>          
                     </mx:Component>          
                </mx:itemRenderer>
    </mx:DataGridColumn>
    Is this what you required ?

Maybe you are looking for

  • External headphones not working (unless plugged in at boot up)

    Hello, I have a MBP 1st gen unibody running 10.5.7. However in last few days my headphones are not working when i plug them in. When i got into system pref-sound it still shows as internal speakers... this is where it goes weird tho: If i boot the ma

  • Please can someone shed some light on what I should do, new to the mac

    Hi all I am looking to purchase a mac, with final cut pro 2. I want all the feature of FCP2 to work smoothly on my mac, so the system requirements need to be up to scratch! Does anyone have a super smooth running mac with FCP2 on it? If so, how much

  • Cannot drill down from 2nd lowest level to lowest level of hierarchy

    In my item master hierarchy, I cannot drill down from the 2nd lowest level (Product Class) to the lowest level (Item Detail). When I add another level between these 2 levels, then I can drill down from Product Class to this new level, but I cannot dr

  • How to change theme without losing parental tabs?

    Hi I want to change the theme of my application from 5 - business to 7 - Centered. After the change I lose the parental tabs.. how can i change the theme without losing the tabs? before: http://img224.imageshack.us/img224/6712/beforewz6.jpg after: ht

  • Incomplete video export

    I have a SD 40 minute sequence in Final Cut which I am exporting in compressor using the DVD best quality settings 90 minutes. Unfortunately, when I import it to DVD studio pro, it is only 17 minutes long. The audio is complete. I've rebooted and re-