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>

Similar Messages

  • 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

  • Using a bitmap object as a item renderer in a datagrid

    I have a UIComponent grabbed has a bitmap, and stored in an
    array collection.
    I want to display a thumbnail in a datagrid, I can make a
    itemRenderer for an image with a local or remote file as a source.
    But how do I use the bitmap in the array collection in an item
    renderer.
    Thanks
    Dean

    Here is an example with a HorizontalList:
    <?xml version="1.0" ?>
    <!-- itemRenderers\htlist\myComponents\Thumbnail.mxml
    -->
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    horizontalAlign="center"
    verticalGap="0" borderStyle="none" backgroundColor="white"
    >
    <mx:Image id="image" width="60" height="60"
    source="{data.image}"/>
    <mx:Label text="{data.name}" width="120"
    textAlign="center"/>
    <mx:Label text="${data.price}" fontWeight="bold"/>
    </mx:VBox>
    <?xml version="1.0"?>
    <!-- itemRenderers\htlistMainlistThumbnailRenderer.mxml
    -->
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml">
    <mx:Model id="catalog" source="catalog.xml"/>
    <mx:HorizontalList id="myList"
    columnWidth="125"
    rowHeight="125"
    columnCount="4"
    dataProvider="{catalog.product}"
    itemRenderer="myComponents.Thumbnail"/>
    <mx:LinkButton label="Product images courtesy of Lavish"
    click="navigateToURL(new URLRequest('
    http://www.shoplavish.com'),
    '_blank')"/>
    </mx:Application>
    <?xml version="1.0"?>
    <catalog>
    <product id="1">
    <name>USB Watch</name>
    <price>129.99</price>
    <image>assets/products/usbwatch.jpg</image>
    <thumbnail>assets/products/usbwatch_sm.jpg</thumbnail>
    </product>
    <product id="2">
    <name>007 Digital Camera</name>
    <price>99.99</price>
    <image>assets/products/007camera.jpg</image>
    <thumbnail>assets/products/007camera_sm.jpg</thumbnail>
    </product>
    <product id="3">
    <name>2-Way Radio Watch</name>
    <price>49.99</price>
    <image>assets/products/radiowatch.jpg</image>
    <thumbnail>assets/products/radiowatch_sm.jpg</thumbnail>
    </product>
    <product id="4">
    <name>USB Desk Fan</name>
    <price>19.99</price>
    <image>assets/products/usbfan.jpg</image>
    <thumbnail>assets/products/usbfan_sm.jpg</thumbnail>
    </product>
    <product id="5">
    <name>Caffeinated Soap</name>
    <price>19.99</price>
    <image>assets/products/soap.jpg</image>
    <thumbnail>assets/products/soap_sm.jpg</thumbnail>
    </product>
    <product id="6">
    <name>Desktop Rovers</name>
    <price>49.99</price>
    <image>assets/products/rover.jpg</image>
    <thumbnail>assets/products/rover_sm.jpg</thumbnail>
    </product>
    </catalog>

  • 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

  • Hiding item renders in Group Datagrid Label Rows?

    I have an Advanced data grid displaying a grouped collection.  I have an item renderer in one column the is a canvas with a button that is bound to the data.
    However, buttons are also showing on the header rows, where they are not needed (see below).  How do I fix this?

    I have an Advanced data grid displaying a grouped collection.  I have an item renderer in one column the is a canvas with a button that is bound to the data.
    However, buttons are also showing on the header rows, where they are not needed (see below).  How do I fix this?

  • Item Renderer for Advance DataGrid

    On AdvancedDataGrid, can we  display one of the column as Text and when the user clicks on the text it should turns into a combo box.
    When the user clicks on any where else it should turn into text back.
    Please help me to implement this.

    Off the top of my head it's probably something like:
    <mx:DataGrid id="dg1" width="100%" height="100%">
    <mx:columns>
    <mx:DataGridColumn dataField="Example">
    <mx:itemEditor>
    <mx:Component>
    <mx:ComboBox>
    <mx:String>1</mx:String>
    <mx:String>2</mx:String>
    <mx:String>3</mx:String>
    </mx:ComboBox>
    </mx:Component>
    </mx:itemEditor>
    </mx:DataGridColumn>
    </mx:columns>
    </mx:DataGrid>
    edit:
    Just checked, Subeesh's example: http://blog.flexmonkeypatches.com/2008/02/18/simple-datagrid-combobox-as-item-editor-examp le/ has got a very good example on it. Pretty much exactly what you asked

  • Re:Item renderer AS3 for datagrid

    I am having a data grid with multiple check boxes for this i am using CheckCellRendererEdit as itemrenderer.When i am making a change in datagrid checkbox its not updating
    The problems are
    1. when i select a checkbox in second row it gets selected in another  row after saving
    2.when i choose one checkbox in a row it gets afftected in many row can i get a solution for this Below given is the code i am using
    CheckCellRendererEdit.as
    package
        import mx.controls.*;
    import mx.core.*;
    import mx.controls.dataGridClasses.DataGridListData;
    import flash.events.Event;
    import flash.events.MouseEvent;
    public class CheckCellRendererEdit extends CheckBox
    // Define the constructor and set properties.
    public function CheckCellRendererEdit() {
        super();
    override protected function clickHandler(event:MouseEvent):void
                if (!enabled)
                {    //DataGrid(this.parentDocument.dg).selectedItem.vdata=CheckBox(event.currentTarget).selec ted;
                        event.stopImmediatePropagation();
                        return;
                if (toggle)
                    selected = !selected;

    Currently i am migrating from flex1.5 to flex2 Just i am using this itemrenderer(checkbox) for DataGrid can i have some ideas for datagrid
    The DataGrid i am using is
    <mx:DataGrid id="screendg" ">
                <mx:columns>
                  <mx:Array>
                    <mx:DataGridColumn headerText="mdata" dataField="screenid" editable="false" />
                    <mx:DataGridColumn headerText="data" dataField="mdata" itemRenderer="CheckCellRendererEdit"  />
                    <mx:DataGridColumn headerText="mdata" dataField="vdata" itemRenderer="CheckCellRendererEdit"  />
                    <mx:DataGridColumn headerText="cdata" dataField="cdata" itemRenderer="CheckCellRendererEdit"  />
                    <mx:DataGridColumn headerText="vdata" dataField="udata" itemRenderer="CheckCellRendererEdit"  />
                </mx:Array>
                </mx:columns>
              </mx:DataGrid>
    When i am selecting a checkbox in data grid the grid value is not getting changed

  • 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

  • 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 destroys on mouse over

    Hi,
         I used Flex 3.5 datagrid. I used item renderes in my datagrid. and i set 'rendererIsEditor = true'.
         Everything is very smooth and good. But somtimes my datagrid acting badly. When i put cursor on itemRenderer, It open-up for
    editing. When i move mouse, item renderer destroyed.
         Once it happens it is the default behaviour of my datagrid. No editing can be performed.
          But i can not reproduce it always. sometimes it a happens.
          please help me. anybody know about this?

    Simplify your test case.  Try using a simple TextInput as the renderer and
    see if you have the same problem.

  • Display item renderer in only some rows of a datagrid

    I need to display a combobox item renderer in my datagrid
    only in the first of every 5 rows. With the remaining 4 rows in
    this particular column empty. Then the pattern will repeat again.
    This is how I am currently creating the columns however with
    this approach the combobox itemrenderer is appearing in all rows
    <mx:columns>
    <mx:DataGridColumn headerText="No."
    dataField="assCriteriaNum" width="60" />
    <mx:DataGridColumn headerText="Assessment Criteria"
    dataField="assCriteria" width="210"/>
    <mx:DataGridColumn headerText="Mark Range"
    dataField="markRange" width="50" />
    <mx:DataGridColumn headerText="Mark" dataField="mark"
    width="70" >
    <mx:itemRenderer>
    <mx:Component>
    <mx:ComboBox>
    <mx:dataProvider>
    <mx:ArrayCollection>
    <mx:String>0</mx:String>
    <mx:String>1</mx:String>
    <mx:String>2</mx:String>
    <mx:String>3</mx:String>
    <mx:String>4</mx:String>
    <mx:String>5</mx:String>
    <mx:String>6</mx:String>
    <mx:String>7</mx:String>
    <mx:String>8</mx:String>
    <mx:String>9</mx:String>
    <mx:String>10</mx:String>
    </mx:ArrayCollection>
    </mx:dataProvider>
    </mx:ComboBox>
    </mx:Component>
    </mx:itemRenderer>
    </mx:DataGridColumn>
    </mx:columns>

    Here is my data provider hard coded
    <mx:dataProvider>
    <mx:ArrayCollection>
    <mx:Array>
    <mx:Object assCriteria="A01 Manage." />
    <mx:Object assCriteriaNum="1" assCriteria="Brief project
    plan, with little evidence of monitoring progress of project work
    against the project plan." markRange="(1-3)" />
    <mx:Object assCriteriaNum="2" assCriteria="Limited
    identification of the topic to be investigated/ researched and
    limited evidence of appropriate aims and objectives, and proposed
    project title." markRange="(1-3)" />
    <mx:Object assCriteriaNum="3" assCriteria="Project plan,
    with some evidence of monitoring progress of project work against
    the project plan." markRange="(4-6)" />
    <mx:Object assCriteriaNum="4" assCriteria="Some
    identification of the topic to be investigated/ researched and some
    evidence of appropriate aims complete the work and objectives, and
    proposed project title." markRange="(4-6)" />
    <mx:Object assCriteriaNum="5" assCriteria="Detailed
    project plan, with clear evidence of monitoring progress of project
    work against the project plan." markRange="(7-10)" />
    <mx:Object assCriteriaNum="6" assCriteria="Clear
    identification of the topic to be investigated/ researched and
    clear evidence of appropriate aims identify the topic and
    objectives, and proposed project title." markRange="(7-10)" />
    <mx:Object assCriteriaNum="7" assCriteria="No relevant
    response." markRange="(0)" />
    <mx:Object assCriteria="A02 Use resources/research."
    />
    <mx:Object assCriteriaNum="8" assCriteria="Little or no
    analysis and application of the research, with few links made to
    appropriate theories and concepts." markRange="(1-5)" />
    <mx:Object assCriteriaNum="9" assCriteria="Evidence of
    limited research involving limited selection and evaluation of
    sources." markRange="(1-5)" />
    <mx:Object assCriteriaNum="10" assCriteria="Some analysis
    and application of the research, with links made to appropriate
    theories and concepts." markRange="(4-6)" />
    <mx:Object assCriteriaNum="11" assCriteria="Evidence of
    some research involving the selection analyse data and evaluation
    of a range of relevant sources." markRange="(4-6)" />
    <mx:Object assCriteriaNum="12" assCriteria="Critical
    analysis and application of the research, with obtain and select
    clear links made to appropriate theories and information from a
    concepts. variety of sources." markRange="(7-10)" />
    <mx:Object assCriteriaNum="13" assCriteria="Evidence of
    detailed research involving the selection and evaluation of a wide
    range of relevant sources." markRange="(7-10)" />
    <mx:Object assCriteriaNum="14" assCriteria="No relevant
    response." markRange="(0)" />
    </mx:Array>
    </mx:ArrayCollection>
    </mx:dataProvider>

  • Item renderer issue

    Hi,
    I have a comboBox as item renderer in my datagrid (comboBox item renderer code bellow).
    1. How can I remove the first blank item? My comboBox arrayCollection doesn't have 0 item.
    2. If I come back to the cell that it was already selected with a value from my comboBox, how can I set the selected item of my comboBox to be the same as the previus value? If I leave the comboBox without selection it will be blank as the 0 element.
    Please help.
    Thanks
    Johnny
    <?xml version="1.0" encoding="utf-8"?>
    <mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml"
                 labelField="label" dataProvider="{acCombo}" rowCount="20"
                 change="onSelectionChange(event)" creationComplete="init()">
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.controls.dataGridClasses.DataGridListData;
                import mx.events.ListEvent;
                import mx.rpc.events.ResultEvent;
                [Bindable]private var acCombo:ArrayCollection = new ArrayCollection ([{id:1, label:"Item 01"},{id:2, label:"Item 02"},{id:3, label:"Item 03"},
                    {id:4, label:"Item 04"},{id:5, label:"Item 05"}]);
                private var _ownerData:Object;
                public function init():void
                    //init code
                override public function set data(value:Object):void
                    if (value){
                        _ownerData = value as Object;
                        var col:DataGridListData = DataGridListData(listData);
                        var item:Object = new Object;
                        var clabel:String = value[col.dataField];
                        var cid:int = value.id;
                        item.label = clabel;
                        item.id = cid;
                        selectedItem = item;
                override public function get data():Object
                    return _ownerData;
                override public function setFocus():void
                    super.setFocus();
                    open();
                private function onSelectionChange(e:ListEvent):void
                    if(selectedItem && _ownerData){
                        var col:DataGridListData = DataGridListData(listData);
                        var clabel:String = selectedItem.label;
                        var cid:int = selectedItem.id;
                        _ownerData[col.dataField] = clabel;
                        _ownerData[id] = cid;
            ]]>
        </mx:Script>
    </mx:ComboBox>

    Hi,
    I created a sample, maybe someone can see the issue for me
    Thanks!
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" viewSourceURL="srcview/index.html"
                    creationComplete="init()">
        <mx:Script>
            <![CDATA[
                import mx.events.CollectionEvent;
                import mx.events.DataGridEvent;
                import com.myItemEditor;
                import mx.collections.ArrayCollection;
                [Bindable] private var acExecution:ArrayCollection = new ArrayCollection([
                    {Territory:"Arizona", Territory_Rep:"Barbara Jennings", ITEM_ID:1, ITEM_NAME:"Item 01"},
                    {Territory:"Central California", Territory_Rep:"Joe Smith", ITEM_ID:2, ITEM_NAME:"Item 02"},
                    {Territory:"Nevada", Territory_Rep:"Bethany Pittman", ITEM_ID:2, ITEM_NAME:"Item 02"}, 
                    {Territory:"Northern California", Territory_Rep:"T.R. Smith", ITEM_ID:1, ITEM_NAME:"Item 01"},
                    {Territory:"Southern California", Territory_Rep:"Jane Grove", ITEM_ID:3, ITEM_NAME:"Item 03"}
                private function init():void
                private function onItemEditEnd(e:DataGridEvent):void
                    var cEditor:myItemEditor = dgCustomEditor.itemEditorInstance as myItemEditor;
                    var item:Object = cEditor.selectedItem;
                    acExecution.refresh();
            ]]>
        </mx:Script>
        <mx:DataGrid id="dgCustomEditor" dataProvider="{acExecution}" height="160"
                     editable="true" itemEditEnd="onItemEditEnd(event)">
            <mx:columns>
                <mx:DataGridColumn headerText="Territory" dataField="Territory" width="60"
                                   editable="false"/>
                <mx:DataGridColumn headerText="Territory Rep" dataField="Territory_Rep" width="60"
                                   editable="false"/>
                <mx:DataGridColumn headerText="Item ID" dataField="ITEM_ID" width="60"
                                   editable="false"/>
                <mx:DataGridColumn headerText="Item Name" dataField="ITEM_NAME" width="160" itemEditor="com.myItemEditor" />
            </mx:columns>
        </mx:DataGrid>
    </mx:Application>
    Item Editor component
    <?xml version="1.0" encoding="utf-8"?>
    <mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml"
                 labelField="LABEL" dataProvider="{acCombo}" rowCount="20"
                 change="onSelectionChange(event)" creationComplete="init()">
        <mx:Script>
            <![CDATA[
                import mx.events.ListEvent;
                import mx.controls.dataGridClasses.DataGridListData;
                import mx.rpc.events.ResultEvent;
                import mx.collections.ArrayCollection;
                [Bindable]private var acCombo:ArrayCollection = new ArrayCollection ([{ID:1, LABEL:"Item 01"},{ID:2, LABEL:"Item 02"},{ID:3, LABEL:"Item 03"},
                    {ID:4, LABEL:"Item 04"},{ID:5, LABEL:"Item 05"}]);
                private var _ownerData:Object;
                private function init():void
                    //init code
                override public function set data(value:Object):void
                    if (value){
                        _ownerData = value as Object;
                        var col:DataGridListData = DataGridListData(listData);
                        var item:Object = new Object;
                        var clabel:String = value[col.dataField];
                        var cid:int = value["ITEM_ID"];
                        item.LABEL = clabel;
                        item.ID = cid;
                        selectedItem = item;
                override public function get data():Object
                    return _ownerData;
                override public function setFocus():void
                    super.setFocus();
                    open();
                private function onSelectionChange(e:ListEvent):void
                    if(selectedItem && _ownerData){
                        var col:DataGridListData = DataGridListData(listData);
                        var clabel:String = selectedItem.LABEL;
                        var cid:int = selectedItem.ID;
                        _ownerData[col.dataField] = clabel;
                        _ownerData["ITEM_ID"] = cid;
            ]]>
        </mx:Script>
    </mx:ComboBox>

  • 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

  • How to overlap datagrid colums line with item renderer

    Hello guys I been stuck for a few days now and I'm wondering if there is a better way to do this.
    I put an item renderer on a column of the datagrid. The renderer basically expands the column height and shows some controls.
    Im using a border container as the container that is holding the items in the grid. However what I would like to do is make the border container as big as the grid with a plus sign button. and then basically hide that  rows vertical grid lines.
    i tried setting the depth eventhought i understant this is not a spark grid i though it should work but it does not. Any tip or direction would be greatly appreciated.
    Miguel

    ok i answered my own question. what i need to do is use the advance datagrid. Then set these properties.
    <mx:AdvancedDataGrid defaultLeafIcon="{null}"
                             folderClosedIcon="{null}"
                             folderOpenIcon="{null}"
                             disclosureClosedIcon="@Embed(source='assets/plusSign.png')"
                             disclosureOpenIcon="@Embed(source='assets/plusSign.png')">
    Message was edited by: miguel8312

  • Datagrid Item Renderer not displaying correct data

    I have a datagrid that displays information from a web service, which is refreshed every 60 seconds.
    When the status is no 0 for a line a corresponding color is used to fill in the background.  I created a Item Renderer to fill in the background color.
    When the table is initially created, the colors are correct.  After the data is refreshed, then the background color value is carried over to the next row.
    The Spark DataGrid works better than the MX AdvancedDateGrid or DataGrid.  This was working in Flex 3, but I used an function which replaced the DataGridColumn that doesn't work in Flex 4.
    protected function init(event:FlexEvent):void
                    var showBackground:Boolean = false;
                    var backgroundColor:uint = new uint();
                    var labelTextColor:uint = new uint();
                    var dgListData:DataGridListData = listData as DataGridListData;
                    var dataGrid:DataGrid = dgListData.owner as DataGrid;
                    // comment this out if you want to see the background over the
                    // selection and highlight indicators
                    if (dataGrid.isItemSelected(data) || dataGrid.isItemHighlighted(data))
                        // clear the background so you can see the selection/highlight colors
                        showBackground = false;
                        return;
                    switch(data["MessageLevel"])
                        case 0:
                            showBackground = false;
                            backgroundColor = 0xFFFFFF;
                            labelTextColor = 0x000000;
                            break;
                        case 1:
                            showBackground = true;
                            backgroundColor = 0x00FF00;  // light green
                            labelTextColor = 0x000000;
                            break;
                        case 2:
                            showBackground = true;
                            backgroundColor = 0x015F00; // dark green
                            labelTextColor = 0xFFFFFF;
                            break;
                        case 3:
                            showBackground = true;
                            backgroundColor = 0xFDFF00; // yellow
                            labelTextColor = 0x000000;
                            break;
                        case 4:
                            showBackground = true;
                            backgroundColor = 0x7F6E3F; // tan
                            labelTextColor = 0xFFFFFF;
                            break;
                        case 5:
                            showBackground = true;
                            backgroundColor = 0xFF8A00; // orange;
                            labelTextColor = 0x000000;
                            break;
                        case 6:
                            showBackground = true;
                            backgroundColor = 0xFFDFE0; // rose
                            labelTextColor = 0x000000;
                            break;
                        case 7:
                            showBackground = true;
                            backgroundColor = 0xFF0000; //red
                            labelTextColor = 0xFFFFFF;
                            break;   
                    if(showBackground) {
                        var bgFill:SolidColor = new SolidColor();
                        bgFill.color = backgroundColor;
                        dataContainer.setStyle("backgroundColor",backgroundColor);
                        lblData.setStyle("color", labelTextColor);

    I added an "else" statement to make sure that a color was always added, even if the level was 0.  I also added a backgroundAlpha style to both, to turn the value off or on.
    So far, this seems to be the solution.
    if(showBackground) {
    var bgFill:SolidColor = new SolidColor();
    bgFill.color = backgroundColor;
    dataContainer.setStyle("backgroundColor",backgroundColor);
    labelDisplay.setStyle("color", labelTextColor);
    dataContainer.setStyle("backgroundAlpha",1);
    } else {
    dataContainer.setStyle("backgroundColor",backgroundColor);
    labelDisplay.setStyle("color", labelTextColor);
    dataContainer.setStyle("backgroundAlpha",0);

Maybe you are looking for