Multi-Use Item Renderer for DataGrid Column

I have a dataGrid where the first column of the grid displays
an icon for the 'type' of item in the row. I created a custom
itemRenderer component which I reference in its own namespace, and
everything works great. Since this is a pretty common concept, I'd
thought that I'd be able to re-use that itemRenderer throughout the
application, but everytime I try to call the itemRenderer in
another dataGrid, I get 2 errors saying "the inlineComponent could
not be found" and then because of that "Access of undefined
property".
It doesn't make sense for an itemRenderer to be only good for
one use, so I'm obviously missing some fundamental issue. Can
someone enlighten me?

Hah, found it. It is an mxml example, and implements
IDropInListItemRenderer. It for an image renderer, but you will be
able to see what to do.
Tracy
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
horizontalAlign="center" verticalAlign="middle"
width="16" height="16"
implements="mx.controls.listClasses.IDropInListItemRenderer"
>
<mx:Script><![CDATA[
import mx.controls.listClasses.IDropInListItemRenderer;
import mx.controls.listClasses.BaseListData;
import mx.controls.dataGridClasses.DataGridListData;
import mx.controls.DataGrid;
[Bindable]
private var source:String;
private var _listData:BaseListData;
public function get listData():BaseListData
return _listData;
public function set listData(value:BaseListData):void
_listData = value;
invalidateProperties();
override protected function commitProperties():void
super.commitProperties();
if (_listData is DataGridListData)
var dgld:DataGridListData = _listData as DataGridListData;
source =
data[DataGrid(dgld.owner).columns[dgld.columnIndex].dataField];
]]></mx:Script>
<mx:Image source="{source}"/>
</mx:VBox>

Similar Messages

  • Item Renderer for DataGrid

    I have a button component as a Item renderer in the column of
    the datagrid .
    I am not able to access the Itemrenderer component(which I
    declared in other mxml file in the datagrid)
    This is the data grid where I have the Itemrenderer:
    <mx:DataGrid id="dgCondition1"
    variableRowHeight="true" width="100%" height="150"
    verticalScrollPolicy="auto" editable="true"
    dataProvider="{initDataGrid_Create}" >
    <mx:columns>
    <mx:DataGridColumn headerText="" dataField="conditi"
    />
    <mx:DataGridColumn headerText="Condition"
    dataField="syntax" width="300" />
    <mx:DataGridColumn headerText="1" dataField="value"
    width="80" editable="false" itemRenderer="buttonRenderer"/>
    <mx:DataGridColumn dataField="value" headerText="2"
    itemRenderer="buttonRenderer" />
    I created a new mxml component for this button component
    .(buttonRenderer.mxml)
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="400" height="300">
    <mx:Script source="..TableDataGridBtn.as" />
    <mx:Button id="col1" label="" width="75"
    click="getDetail(event,col1)" />
    </mx:VBox>
    The Problem is I am not able to access the buttonRenderer in
    the datagrid itemRenderer tag .
    It says "Access of Undefined Property buttonRenderer".

    "nash99" <[email protected]> wrote in
    message
    news:g7alc5$nkd$[email protected]..
    > So
    > Is it that I can Use this ItemRenderer tag in the
    Application Tags only
    > Is there any other way I can use them in mxml components
    because I am
    > using
    > the same button in 16 datagrid columns , I dont wan't to
    make the code
    > look
    > redundant.
    http://www.adobe.com/livedocs/flex/3/html/help.html?content=intro_3.html

  • Using item renderer in datagrid

    Hi there,
    I am trying to pass boolean data from a VO into a selected property of a checkbox component. Any thoughts on how to do this?
              <mx:DataGridColumn headerText="Active" width="60" dataField="active"> <--- need to pass this into  the selected property
                   <mx:itemRenderer>
                        <mx:Component>
                             <mx:Box horizontalAlign="center">
                                  <mx:CheckBox />
                             </mx:Box>
                        </mx:Component>
                   </mx:itemRenderer>
              </mx:DataGridColumn>

    <mx:itemRenderer>
         <mx:Component>
              <mx:CheckBox selected="{Number(data.active)==1?true:false}" click="data.active=data.active" textAlign="center"/>
         </mx:Component>
    </mx:itemRenderer>
    The click event is present to prevent the user form changing the checkbox state. Hope this works for you.

  • 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

  • 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

  • Item renderer for specific rows

    I need to have a checkbox item renderer for a spark datagrid column. I am using the following to get an item renderer into column:
    var checkBoxRenderer:ClassFactory = new ClassFactory(GridCheckBoxItemRenderer);
    column.itemRenderer = checkBoxRenderer;
    My question is if I need to show a checkbox for specific rows can I do that without going into GridCheckBoxItemRenderer's source code?
    Thanks

    Hi Zolotoj ,
    Please go through following links :
    http://stackoverflow.com/questions/1952940/show-itemrenderer-in-specific-datagrid-rows-oth ers-empty
    http://www.flexer.info/2009/01/09/different-rows-in-datagrid-programmatically-added-itemre nderers-classfactory-and-ifactory/
    It will provide you some idea to how to proceed further for this problem.
    Thanks and Regards,
    Vibhuti Gosavi | [email protected] | www.infocepts.com

  • How to use simple types for table column names ?

    Hi,
    can any one tell how to to use simple types for table column names?
    It is required in internationalizing of webdynpro applications.
    Regards,
    Rajesh

    Hi,
    1: define required column names in <SimpleType>
    2:use the following code to get those values
    3:bind 'text' property of Column headers to context attributes
    4:take a context attribute 'Value' as type of <SimpleType>
    5:set these values to context attributes
    IWDAttributeInfo objAttrInfo=wdContext.getNodeInfo().getAttribute(IPrivate<ViewName>View.IContextElement.VALUE);
    ISimpleTypeModifiable simple=objAttrInfo.getModifiableSimpleType();
    Map m=simple.getEnumerationTexts();
    Collection c=m.values();
    Iterator it=c.iterator();
    if(it.hasNext())
    wdContext.currentContextElement.set<att1>(it.next().toString);
    if(it.hasNext())
    wdContext.currentContextElement.set<att2>(it.next().toString);
    if(it.hasNext())
    wdContext.currentContextElement.set<att3>(it.next().toString);
    Regards
    LakshmiNarayana

  • Using number datatype for date column

    Hi
    Is there a side effect for using "number" datatype for "date" column?
    If so, what is the disadvantage?
    Many thanks

    Hi,
    Ora_83 wrote:
    Hi
    Is there a side effect for using "number" datatype for "date" column?
    If so, what is the disadvantage?Yes, there's a definite disadvantage.
    Oracle provides date arithmetic and a number of functions for manipulating DATEs. None of them work with numbers.
    For example,
    SELECT    TRUNC (order_date, 'MONTH')     AS order_month
    ,       AVG (ship_date - order_date)     AS avg_delay
    FROM       orders
    GROUP BY  TRUNC (order_date, 'MONTH')
    ;order_month involves a DATE function; it's pretty easy to find the month that conatins order_date.
    avg_delay involves date arithmetic. It's extrememly easy to find how much the time passed between order_date and ship_date.
    Depending on how you code dates as numbers, doing either one of the above may be just as easy, but doing the other will be very difficult. You'll waste a lot of effort converting the NUMBERs to real DATEs whenever you need to manipulate them.
    Validation can be very difficult for NUMBERs, also.
    Watch this forum. It's a rare day when there's not some question about how to get around a problem caused by storing dates in a NUMBER (or VARCHAR2) column. Don't add to that. Always use DATE columns for dates.

  • Generic item renderer for Adv DG Columns?

    Hello,
    I'm trying to create a generic ItemRenderer for my Adv DG so that so that I can put a toolTip on the cells.
    The Adv DG Column object doesn't have a toolTip property so I'm creating my own renderer...
    As far as I'm aware I have to create an ItemRenderer that knows the fieldName that it is rendering so I can use {data.myFieldName}. I was hoping there was a property so that I can reference the value generically such as {data.text} but this obvisouly doesn't work...
    Is there anyway around this? Can I pass a paramater to the itemRenderer? I'm doing it like this...
    advancedDataGridColumn.itemRenderer = new ClassFactory(renderers.ToolTipFieldRenderer);
    Alsok, there is a toolTip property of the AdvDG but the columns, what is the AdvDG.toolTip used for? Just a general toolTip? The reason why I need a toolTip is our client has asked to be able to mouse-over the cell to see the full value where the field value is chopped because it's too long for the column...
    Hope that makes sense and hope you can help...
    Cheers,
    Nick

    The AdvancedDataGridColumn class has dataTipField and dataTipFunction
    properties and these are supported by the default item renderer
    (AdvancedDataGridItemRenderer), which is also generic. Here's an example:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="absolute">
      <mx:Script>
          <![CDATA[
             import mx.collections.ArrayCollection;
             private var dpADG:ArrayCollection = new ArrayCollection([
          ]]>
        </mx:Script>
        <mx:AdvancedDataGrid
            height="400"
            width="300"
            sortExpertMode="true"
            dataProvider="">
            <mx:columns>
                <mx:AdvancedDataGridColumn
                    dataField="Artist"
                    dataTipField="Artist"
                    showDataTips="true" />
                <mx:AdvancedDataGridColumn
                    dataField="Album"
                    dataTipField="Album"
                    showDataTips="true" />
                <mx:AdvancedDataGridColumn
                    dataField="Price"
                    dataTipField="Price"
                    showDataTips="true" />  
            </mx:columns>
       </mx:AdvancedDataGrid>      
    </mx:Application

  • 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

  • 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

  • Problem with checkbox item renderer in datagrid

    I have a data grid having check box as an item renderer. I have viewed many posts in this forum but nothing useful in my case. I am failed to bind my datagrid itemrenderer checkbox with the field of dataprovider i.e. listUnitMovement.CHECK_PATH. Then I have to traverse data provider to check which checkboxes are checked.
    [Bindable]
    var listUnitMovement:XMLList=null;                      
    In a function call
    public function init(event:ResultEvent):void
        listUnitMovement=event.result.unitmovement;
         <mx:DataGrid id="dg_country"
                               dataProvider="{listUnitMovement}"
                                  enabled="true">
                                <mx:columns>
                                   <mx:DataGridColumn>
                                        <mx:itemRenderer>
                                            <mx:Component>
                                                <mx:CheckBox selectedField="CHECK_PATH"  />
                                            </mx:Component>                                       
                                        </mx:itemRenderer>
                                    </mx:DataGridColumn>
                                    <mx:DataGridColumn headerText="Latitude" dataField="NEW_LAT" visible="false"/>
                                    <mx:DataGridColumn headerText="Longitude" dataField="NEW_LONG" visible="false"/>
                                   <mx:DataGridColumn>
                                        <mx:itemRenderer>
                                            <mx:Component>
                                                <mx:Button label="Details"/>
                                            </mx:Component>                                       
                                        </mx:itemRenderer>
                                    </mx:DataGridColumn>
                                </mx:columns>
                            </mx:DataGrid>

    Hi,
    Do you want to just check/uncheck the checkboxes based on the CHECK_PATH field.
    Do you want something like this...
    <?xml version="1.0" encoding="utf-8"?><mx:Application  xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
     <mx:Script>
    <![CDATA[
     import mx.collections.ArrayCollection;[
    Bindable] 
    private var listUnitMovement:ArrayCollection = new ArrayCollection([{CHECK_PATH:true,NEW_LAT:109.233,NEW_LONG:232.22},{CHECK_PATH:true,NEW_LAT:109.233,NEW_LONG:232.22},{CHECK_PATH:false,NEW_LAT:133.233,NEW_LONG:702.22}]);]]>
    </mx:Script>
     <mx:DataGrid dataProvider="{listUnitMovement}">
     <mx:columns>
     <mx:DataGridColumn>
     <mx:itemRenderer>
     <mx:Component>
     <mx:CheckBox selectedField="CHECK_PATH" change="data.CHECK_PATH=selected" />
     </mx:Component>  
    </mx:itemRenderer>
     </mx:DataGridColumn>
     <mx:DataGridColumn dataField="NEW_LAT"/>
     <mx:DataGridColumn dataField="NEW_LONG"/>
     </mx:columns>
     </mx:DataGrid>
    </mx:Application>
    Please let me know clearly what's your problem...Do you want to just bind the check box based on XmlList or something else..?
    Thanks,
    Bhasker Chari.S

  • 'id' attribute is not rendered for h:column tag in datatable

    Hello Everyone,
    There is a problem with rendering 'id' attribute for <h:column> tag. I'm using jsf 1.2_07.
    Here is source code:
    <h:dataTable id="reportList" var="item" cellpadding="1" cellspacing="0" border="0" value="#{myBean.reportList}">
    <h:column id="column1">
    <f:facet name="header">
    <h:outputText value="#{textProps.selected}" style="white-space:nowrap;"/> </f:facet>
    <h:selectOneRadio id="radio" onclick="javascript:setselected(this);">
    <f:selectItem itemValue="#{item.id}"/>
    </h:selectOneRadio>
    </h:column>
    <h:column id="column2">
    <f:facet name="header">
    <h:outputText value="#{textProps.name}" style="white-space:nowrap;"/>
    </f:facet>
    <h:outputText value="#{item.name}" style="white-space:nowrap;"/>
    </h:column>
    </h:dataTable>
    Thanks for your help,
    Sergei

    The attribute "id" is set properly but isn't shown in html
    because there is no html-element corresponding to UIColumn.

  • Item renderer in datagrid with actionscript

    Hi
    I want to implement a datagrid similar to the one given int
    the starting flex examples but in actionscript. I am having a
    problem with the itemRenderer. I can't figure it out how I cam
    create a imagerender in a datagridcolumn.
    My code is:
    var dataG:DataGrid = new DataGrid();
    dataG.dataProvider = xmlList;
    var coluna:DataGridColumn = new DataGridColumn();
    coluna.dataField="nome";
    coluna.headerText="Title";
    var coluna2:DataGridColumn = new DataGridColumn();
    coluna2.dataField="thumbnail";
    coluna2.headerText="Title";
    var imagem:Image = new Image();
    imagem.height = 75;
    imagem.source = "../tb/"+instrumentos.thumbnail+".jpg";
    //HERE RELIES MY PROBLEM -HOW TO ASSOCIATE AN IMAGE TO THE
    ITEM RENDERER
    coluna2.itemRenderer = new ClassFactory(imagem);
    var lalala:Array = new Array();
    lalala.push(coluna);
    lalala.push(coluna2);
    dataG.columns = lalala;
    thanks in advance

    "jahh_drum" <[email protected]> wrote in
    message
    news:ghcs5u$p2d$[email protected]..
    > Hi
    >
    > I want to implement a datagrid similar to the one given
    int the starting
    > flex
    > examples but in actionscript. I am having a problem with
    the itemRenderer.
    > I
    > can't figure it out how I cam create a imagerender in a
    datagridcolumn.
    >
    > My code is:
    >
    > var dataG:DataGrid = new DataGrid();
    > dataG.dataProvider = xmlList;
    >
    > var coluna:DataGridColumn = new DataGridColumn();
    > coluna.dataField="nome";
    > coluna.headerText="Title";
    >
    > var coluna2:DataGridColumn = new DataGridColumn();
    > coluna2.dataField="thumbnail";
    > coluna2.headerText="Title";
    >
    >
    > var imagem:Image = new Image();
    > imagem.height = 75;
    > imagem.source = "../tb/"+instrumentos.thumbnail+".jpg";
    >
    > //HERE RELIES MY PROBLEM -HOW TO ASSOCIATE AN IMAGE TO
    THE ITEM
    > RENDERER
    > coluna2.itemRenderer = new ClassFactory(imagem);
    >
    > var lalala:Array = new Array();
    > lalala.push(coluna);
    > lalala.push(coluna2);
    >
    > dataG.columns = lalala;
    ClassFactory takes a class, not an instance.
    Try something like:
    foo:ClassFactory = new ClassFactory(Image)
    foo.properties= {height=75,
    source:"../tb/"+instrumentos.thumbnail+".jpg"};
    coluna2.itemRenderer = foo;
    Note that using a ClassFactory this way will give you the
    same image in
    every renderer to start out with. However, I believe that
    image
    itemRenderers by default will take their source from the data
    property when
    that gets set.
    HTH;
    Amy

  • Edit Renderer for Date columns

    I tried to use EditRenderer for a column that is a Date. BC4J automatically renders this as DateField, but I don't want this, so I set the EditRenderer to something else. But it seems BC4J ignores this and renders it as DateField (for Varchar fields it works well).
    I use JDev 9.0.3.3 and UIX+JSP.

    I found it out: on the Control Hints tab change the Control type from "default" to "edit" and the EditRenderer works

Maybe you are looking for