Datagrid and multiple ItemRenderer

What I would like to do and haven't been successful is add a column to a Datagrid at runtime.  Each cell in that column is going to be different based upon user data. The first column is populated based upon a user query then another query (i.e. RESTful query) is made to mashup some data.
I wanted a button (mashup data) to appear in the column enabled if data was available and disabled if data was not available.
I was doing something like this:
My MXML file has this:
        <mx:DataGrid id="dg" dataProvider="{ModelLocator.getInstance().list}" itemClick="itemClickHandler(event)" left="10" right="0" bottom="0" top="50" editable="true" >
            <mx:columns>
                <mx:DataGridColumn headerText="Name" dataField="name" editable="true" />
                 <mx:DataGridColumn headerText="Data" dataField="someData" itemRenderer="ActionButtonItemRenderer" />
            </mx:columns>
        </mx:DataGrid>
ActionButtonItemRenderer.as file:
    public class ActionButtonItemRenderer extends Button
        public function ActionButtonItemRenderer()
            super();
            label = "Show Data";
        override public function set data(value:Object):void {
            if (null == value.myData) {
                label = "";
                this.enabled = false;
        // Handle the search button event.
        override protected function clickHandler(event:MouseEvent):void
            // Code omitted here...
It works but when I use my mouse wheel to scroll through the records the buttons get all hosed up and the enabled buttons become disabled.  It's weird.
Thanks!

You create an ArrayCollection or XMLListCollection and populate it initially with perhaps data that would represent "no data".
Then if your queries return real data, the dataProvider object now "has data".
The itemRenderer does the appropriate thing if there is not is no data.
You don't generate the button in the dataProvider, you just get the label and visible property value etc. from the dataProvider.
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

Similar Messages

  • PlotSeries (One serie and multiple itemRenderer)

    Hi all,
    I'm working in charts, concretely with a PlotChart.
    Its code:
    <mx:PlotChart  id="plot" width="100%" height="100%"
                    dataProvider="{chartList.arrRouting}"
                    showDataTips="true">
                  <mx:horizontalAxis>
                       <!--<mx:CategoryAxis categoryField="time"/>-->
                       <mx:DateTimeAxis  alignLabelsToUnits="true" dataInterval="2"
                            dataUnits="hours" parseFunction="myParseFunction"/>
                  </mx:horizontalAxis>
                   <mx:verticalAxis>
                   <mx:CategoryAxis dataProvider="{chartList.arrcoll2}"/>
                   </mx:verticalAxis>
                   <mx:series>
                        <mx:PlotSeries id="pSeries" xField="time" yField="node"
                             fillFunction="myFillFunction"/>                    
                   </mx:series>     
    </mx:PlotChart>
    DataProvider is an array like this: [event:'NodeConnected', time:'23:53', node:'A']
                                                     [event:'NodeDisconnected', time:'02:53', node:'A']
                                                     [event:'RemoveRouteTo', time:'01:53', node:'B'];
                                                     [event:'NewRouteTo', time:'23:53', node:'C']............................
    And I use a fill function:
              private function myFillFunction(element:ChartItem, index:Number):IFill{
                   var c:SolidColor = new SolidColor(0x00CC00);
                   var item:PlotSeriesItem = PlotSeriesItem(element);
                   if (item.item.event == 'NewRouteTo'){
                        c.color =0x01DFD7;
                        return c;
                   if (item.item.event == 'RemoveRoute'){
                        c.color = 0xF7FE2E;
                        return c;
                   if (item.item.event == 'NodeConnected'){
                        return c;
                   }else {
                c.color = 0xFF0000;
                   return c;
    Then, I want to change the itemRenderer (icon) acorrding to param Event. As I have only one serie all items are with a circle (default Item Renderer),
    I try to put in myFillFunction the next code: pSeries.setStyle("itemRenderer", new ClassFactory(mx.charts.rendereres.CrossItemRenderer)); but doesnt work.
    Is it possible to do that?
    Thanks in advance,

    Hi,
    if you set itemRenderer for series, all items will be rendered using this class.
    If you want to have different pictures for items in one series you should create your own itemRenderer and change the symbol accoding data.
    For example,
    public class MyCoolItemRenderer extends ProgrammaticSkin implements IDataRenderer
    ... // do something
    override protected function updateDisplayList(unscaledWidth:Number,
      unscaledHeight:Number):void
    super.updateDisplayList(unscaledWidth, unscaledHeight);
    var stroke:Stroke = getStyle("stroke");
    var g:Graphics = graphics;
    g.clear();
    g.lineStyle(stroke.weight, stroke.color, stroke.alpha);
    switch (data.event)
         case "NewRouteTo":
              g.drawCicle(0, 0, unscaledWidth); // just an example. You can show the way of rendering items in SDK source
              break;
    g.endFill();

  • How to delete a selected row from datagrid and how to create a datagrid popup

    hi friends,
                  I am new to flex.i am doing a flex4 application,i need help for this.
                i am having a data grid with columns.i have two questions.
               Ques 1: when  i selected a partiuclar row from a datagrid and click delete button  means that record will delete from the datagrid and DTO from the cloud  tables also.
                Ques 2: when i save  the data grid values using save button means that data will store in  respective cloud DTO which is related to the datagrid,
                     My requirement is i am using a search button when i click the search  button it will show a datagrid that datagrid will contain the previous  datagrid datas which is saved in the cloud.
    REQUIREMENT example: first screen:           i am using with data grid 3 columns (Student Roll number ,Student Name,Student pecentage)---->save--->data will store in cloud DTO.
    Second screen:                search button ----> it need show  datagrid popup.it will have data which we saved in the first screen with same columns(Student Roll number ,Student Name,Student pecentage).
    This is my requirement.
    Any suggession welcome.
    Thanks in advance.
    B.Venkatesan

    Lets break the problem statement in multiple steps
    1. We need a way to know the selection on all rows.
    2. We need the association of the checkBox with the data
    The  solution is to use a arrayCollection/array that holds all the instances  created for checkbox.This collection should be a property of component  containing the datagrid. We need to use a custom component  implementation or inline ItemRenderer. The way you have used is called  dropinItemRenderer. Preferaly use custom component implementation and  add the instance to the arrayCollection at CreationComplete. Make sure  you use addItemAt so that you add the instance in the same row as the  data. To get rowIndex the custom Checkbox should implement  IDropInListItemRenderer. You could iterate this collection to check all  the instances that are checked.
    Note: This is the approach considering your dataprovider doesnt have a selection field.
    Nishant

  • How to delete a Selected row from datagrid and how to create a datagrid popup with saved values

    hi friends,
                  I am new to flex.i am doing a flex4 application,i need help for this.
                i am having a data grid with columns.i have two questions.
               Ques 1: when i selected a partiuclar row from a datagrid and click delete button means that record will delete from the datagrid and DTO from the cloud tables also.
                Ques 2: when i save the data grid values using save button means that data will store in respective cloud DTO which is related to the datagrid,
                    My requirement is i am using a search button when i click the search button it will show a datagrid that datagrid will contain the previous datagrid datas which is saved in the cloud.
    REQUIREMENT example: first screen: i am using with data grid 3 columns (Student Roll number ,Student Name,Student pecentage)---->save--->data will store in cloud DTO.
    Second screen: search button ----> it need show  datagrid popup.it will have data which we saved in the first screen with same columns(Student Roll number ,Student Name,Student pecentage).
    This is my requirement.
    Any suggession welcome.
    Thanks in advance.
    B.Venkatesan

    Lets break the problem statement in multiple steps
    1. We need a way to know the selection on all rows.
    2. We need the association of the checkBox with the data
    The  solution is to use a arrayCollection/array that holds all the instances  created for checkbox.This collection should be a property of component  containing the datagrid. We need to use a custom component  implementation or inline ItemRenderer. The way you have used is called  dropinItemRenderer. Preferaly use custom component implementation and  add the instance to the arrayCollection at CreationComplete. Make sure  you use addItemAt so that you add the instance in the same row as the  data. To get rowIndex the custom Checkbox should implement  IDropInListItemRenderer. You could iterate this collection to check all  the instances that are checked.
    Note: This is the approach considering your dataprovider doesnt have a selection field.
    Nishant

  • I have one apple ID and multiple family members share this with their devices.  How do we keep pics and messages separate?

    I have one apple ID and multiple family members share this with their individual devices.  How do we keep pics and messages separate for each device?

    For messages
    MacMost Now 653: Setting Up Multiple iOS Devices For Messages and FaceTime
    For other issue:
    How to use multiple iPods, iPads, or iPhones with one computer
    What is the best way to manage multiple...: Apple Support Communities

  • New 13" Macbook Pro trying to connect to a Panasonic VIERA TC-L42U30 as second monitor. I've used multiple hdmi-thunderbolt/mini displayport adapters and multiple hdmi cables and still no success. The Macbook does not sense the second monitor (TV). Help?!

    I've been a Mac since 2008, so I know my way around the system pretty well. This issue, however, has me stumped. I had an iMac until now and only now am I experiencing some difficulty with my new MacBook Pro. The model I have is the newest 13" Macbook Pro model and I'm trying to connect a Panasonic VIERA TC-L42U30 42" HDTV as a second monitor via the Thunderbolt port.
    It worked the first two times and hasn't worked since, after 10-15 attempts with different configurations, turning things on n off, restarting the mac, unplugging the cables, adapters, TV, resetting the P RAM, etc... I've used multiple hdmi-thunderbolt/mini displayport adapters and multiple hdmi cables and still no success. No matter what I do, the Macbook does not sense the TV as a second monitor anymore.
    I took the MacBook Pro to the Apple Store, and their "genius" there had it working fine with a DVI connection to a regular monitor. The Panasonic TV I have has HDMI connections and one VGA connection which does not support HD, but no DVI option. I want an HD connection to mirror or extend my MacBook Pro screen. At the Apple Store, they didn't have a Thunderbolt/Mini DisplayPort to HDMI adapter, so he could not try that out for me.
    Anyone else have this configuration or another similar one with a Panasonic HDTV?
    Ideas? Suggestions? Anything?! Help!!
    P.S. I'm running Mountain Lion, if that wasn't already obvious. Everything is up to date in my App Store as well.
    Thanks!

    Hi There,
    I have had the exact same issue but with a projector.
    The issue lies with Mountian Lion 10.8.2.
    I tried many a combination with no luck to get HDMI working.
    Took my mac into the apple store and came to the conclusion it was the software, so I asked them to install 10.8 onto it (this is destructive so a backup is a must)
    Bought my macbook home and voila, now displaying through my projector.
    There is a small graphics update after 10.8.1 which seems to be the cause.
    Hope this helps.
    Thanks.

  • Hello,  I have iMac from Oct, 2010 and have OS 10.6.7 and multiple users.  Mail icon was accidently removed along with program.  Mail 4.4 is on other users but when I reloaded software my user got Mail 4.3. Mail 4.3 did not work with latest OS. Ideas?Matt

    Hello,  I have iMac Itel i3, from Oct, 2010 and have OS 10.6.7 and multiple users. 
    About 3-4 days ago the Mail icon in dock had question mark and was accidently removed, along with program on my user.  Oops.
    1. Mail 4.4 is on other users and works fine, but for me it does not work and tells me V4.3 does not work with latest OS X. 
    2. I reloaded software from my user with original disks  (Oct, 2010) and got Mail 4.3 again. Mail 4.3 did not work with latest OS.  I am unable to load Mail.  Gives Yellow error message.    
    "  You have Mail version 4.3 (1081/1084). It can’t be used on Mac OS X Version 10.6.7 (Build 10J869). For more information, click the Help button."
    3. Tried to update software and look for update for mail 4.3 on Apple site to no success.
    Hate to go to MS-Entorage ( I may need to learn something new and alien) mail program since contracts are in Mail/Address Book.
    Ideas?
    MattDeeds

    Matt,
    I would download and run the 10.6.7 combo update.
    http://support.apple.com/kb/DL1361
    Regards,
    Captfred

  • Can I use one itunes account for multiple users and multiple devices

    Can I use one itunes account for multiple users and multiple devices?

    The iTunes EULA, as I understand it (I'm not an attorney )for Apps is basically that one person can use an App multiple devices, or multiple people can use an App one device..so one to many or many to one, but not many to many....

  • How to bundle a .FLA and multiple .SWF files in one .EXE?

    Hi,
    I have a .FLA file which uses loadMovieNum() to load various
    .SWF files when each one is called by the user clicking on a
    button. Each .SWF file also uses loadMovieNum() to call a second
    .SWF file. When I publish the .FLA file as a .SWF file it all works
    beautifully.
    Now I need to package the entire project into a Windows
    projector .EXE file for offline use on a computer without the Flash
    Player. When I publish the main .FLA file as a .EXE file, the .SWF
    files still load, although they blink before fully loading and
    displaying steadily.
    What I would really like to do is to bundle all the .SWF
    files into the .EXE file so when I send the finished project to the
    end user, they only have to deal with one file, rather than a
    folder with the .EXE file and multiple .SWF files.
    Is there a way to do this?
    I am using Flash 8 Professional.
    Thanks,
    Cam

    Since this isn't going to be web-based, why not include all
    the external swf files into the same Flash file and then use
    attachMovie?
    This will allow you to create one .exe file that would
    contain EVERYTHING. Since you aren't worried about loading speeds,
    you don't have to load the movie clips, but can simply create one
    large Flash file.

  • One premium account and multiple Skype HD devices

    Will one Premium account and multiple non premium HD accounts work for video calling? Basically the idea is 10 HD skype devices, the set top boxes connected to tvs will dial into one Premium Mac or PC account for multiple video conferencing.

    Yes, one user needs to have a Group Video Calling subscription.
    Unfortunately, not all devices support Group Video calling (TV's for example, do not).
    Please see our website for more information: http://www.skype.com/en/features/group-video-chat/.

  • HT4137 iCloud setup with one Apple ID and multiple devices

    iCloud setup with one Apple ID and multiple devices

    What, exactly, are you trying to do? You can use the same iCloud account on as many devices as you want, as long as you don't turn on iTunes Match. Once you turn on Match, you're limited to 10 devices total.
    Is this what you want to do...same iCloud account, but different iTunes/App store accounts on each device? If so, you can do that also.

  • I have two macs at my house, and multiple iPhones. I want to keep the same apple id as everyone else, but i want to put my own music only on my iPhone. I want to do this with my laptop which is not the family's main iTune's computer.

    I have two macs at my house, and multiple iPhones. I want to keep the same apple id as everyone else, but i want to put my own music only on my iPhone. I want to do this with my laptop which is not the family's main iTune's computer.

    If you use the same Apple ID for iCloud on each device, yes. However, you can use the same Apple ID for iTunes content on each device, but different Apple ID's for iCloud, iMessage, FaceTime, etc., on each device. That way, you can have whatever iTunes content you want on each phone, but keep all of the other data separate. You can create another Apple ID here:
    https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/wa/createAppleId?loca lang=en_US
    Must be a verified email address.

  • Totally confused with iCloud and multiple devices

    Ok, So we have two each of the iPods, iPads and now iPhones.  Do we all share the same iCloud? Can we share apps through the cloud? How do I switch my iPad to the new one I got to give this one to my son. I am so new to all this apple stuff. Only been a few months and I'm still really confused.  What all goes to the iCloud? How do we see what's in the iCloud?  I really the the idiots instructions I think to figure this all out?  Can anyone help me?  How can I print from the iPad?  Everything I see says iOS 10 something?  I believe I only have 6 something? 

    Do we all share the same iCloud?
    icloud is designed so that only one user uses it to keep his/her devices in sync.  When multiple users use the same icloud account, they will then be sharing the same email address, contacts, calendars, notes, etc.  Usually that is not what two people want to do.
    Can we share apps through the cloud?
    You buy apps from the itunes store, that's different than icloud, and multiple users can use the same itunes account so that they can share apps, music, etc.  For a family, everyone usually uses the same Apple ID for an itunes account and individual Apple IDs for their icloud accounts.
    How do I switch my iPad to the new one I got to give this one to my son.
    What do you mean by "switch.. ipad to the new one"?
    What all goes to the iCloud?
    Backups of iOS devices, Apple services that you turn on to share data (settings>icloud; on an iOS device), third party apps that use icloud to sync their data between devices, email, photo stream, and more.
    How do we see what's in the iCloud? 
    Icloud is designed primarily for syncing data between the devices of the user - like getting all computers and devices to have the same contacts or calendars.  When you set up syncing (settings>icloud, turn on the services you want synced between your devices), some of that data will also be available to a computer's browser when you log into icloud.com.  Otherwise you view the data using the associated app, like the Calendar app to see events.  Other things that may be on icloud, like backups cannot be seen.  Also iCloud does not provide a photo gallary that others can view in a browser.
    How can I print from the iPad? 
    For that you need an "airprint" compatible printer. See,
    http://support.apple.com/kb/ht4356
    You can also print to a printer that's connected to a computer, but that computer needs special software, like Printopia for macs.
    Everything I see says iOS 10 something?  I believe I only have 6 something?
    There is no "10", version 6 is the current one.  You are probably thinking of OSX, whose versions are 10.x.y.  That's for macs, not iOS devices.

  • When I went to bed I had 3,000  song and multiple playlists.  This morning I have ~30 songs and no playlists.  What could have happened to my songs playlists?  I run iTunes on a Windows 7 64-bit machine.  HELP! (oh, and the Songs are not in recycle bin)

    When I went to bed I had 3,000  song and multiple playlists.  This morning I have ~30 songs and no playlists.  What could have happened to my songs playlists?  I run iTunes on a Windows 7 64-bit machine.  HELP! (oh, and the Songs are not in recycle bin)
    My wife's ipod nano was plugged into the machine overnight.
    When she went running with it, there were no songs on it.  She checked the computer and was horrified to see that the playlists had disappeared and most of the songs had disappeared.
    QUESTIONS:
    1. What could it be?
    2. How can I fix it?

    Hi, there alot of us suffering from this phernomonon but there is a forum topic about is already.
    https://discussions.apple.com/message/16767377#16767377
    Come check it out.
    Hope this works out for all of us.

  • How to get the Dataprovider var of a Datagrid inside an ItemRenderer?

    Hey,
    I have two Datagrids, both of them have a bindable dataprovider. My first Datagrid has an ItemRenderer. I would like to update my dataprovider inside the ItemRenderer. Is it possible? My ItemRenderer is a Combobox. Everytime I change the Combobox I would like to update/refresh the dataprovider for my datagrid. I tried it with but it doesn´t work.(parentDocument
    as filename).dataProvider.source=sth.;
    (parentDocument as filename).dataProvider.refresh();
    Regards
    Kat

    The parent document of an itemRenderer is not always what you expect.
    You're better off using the listOwner property on listData.
    http://livedocs.adobe.com/flex/3/langref/mx/controls/ComboBox.html#listData
    http://livedocs.adobe.com/flex/3/langref/mx/controls/listClasses/BaseListData.html#owner

Maybe you are looking for

  • I want a book  for toplink

    Hai In our project we plan to use the top link with entity bean we plan to use top link as cache also so any material related to this or any web site or any book give me the detail I can’t under stand the flow so please help me related to this . th

  • Messages and facetime complain about incorrect ID and password

    I have an issue after upgrading to Mountain Lion - Messages and Facetime dont sign in?  Is anyone facing this problem and if anyone found a fix for it, please reply back to this post.... Thanks Krish

  • Adjusting Audio Volume Levels

    Often, one has Audio that is too loud, or too soft. Sometimes, they have added a music Track, that needs to drop down to clearly hear the dialog from another Clip. While there are Audio-editing programs, like Audition, SoundBooth, and even the free A

  • Set up grid control for Oracle application 11i

    Hi, I want to set up the grid control for his/her application 11i. Our system is on 11.5.10.2 and the database is 10.1.0.4 Is there any good documentation for this? Thanks, Lily

  • Adaptive Wide Angle (PS CS6) - Auto doesn't work

    When I try to use "Auto" correction in the new Adaptive Wide Angle filter, it pops up with "No matching lens profile found". I searched for information and was directed to go to the Lens Correction filter. I pressed the "Search Online" button. The fi