How do you programmatically change an image in DataGrid cell

I have a DataGrid which contains a status icon. I have been able to get the initial status icon to show in the DataGrid. But I am unable to update the it. I basically need to update the image for a selected row with either a 'assets/processing.png',  'assets/success.png' or 'assets/failure.png' image. I just cannot seem to be able to figure out how to get access to the image in the necessary cell to update/replace it. I've tried to make it a property of my ArrayCollection data provider, but that does not work. I've also have tried to some how get a reference to the original image so it can be replaced, but cannot figure out how to do such. Below is the code to my DataGrid. I will be very appreciative of any help on this. (I'm relatively new to Flex/ActionScript, but a seasoned developer otherwise.)
<mx:DataGrid id="myDataGrid" left="0" top="0" bottom="0" right="0"
                     allowMultipleSelection="true" verticalScrollPolicy="on"
                     draggableColumns="false" resizableColumns="false" sortableColumns="false"
                     dataProvider="{myArrayCollection}">
            <mx:columns>
                <mx:DataGridColumn headerText="Name" dataField="name" wordWrap="true" />
                <mx:DataGridColumn headerText="Status" dataField="status" width="75" textAlign="center">
                    <mx:itemRenderer>
                        <mx:Component id="statusComponent">
                            <mx:HBox id="imageBox" width="100%" height="100%" horizontalAlign="center">
                                <mx:Image id="statusImage" source="@Embed('assets/pending.png')" width="16" height="16"  />
                            </mx:HBox>
                        </mx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>
            </mx:columns>
        </mx:DataGrid>

Mark,
My sincerest thanks for your assistance. myDataGrid.invalidateList() the key thing I was missing in all my previous attempts. I had thought about  needing to do something to refresh the grid, but was looking for a "refresh" method. I did not see the invalidateList() method.
To get it to work I needed to override the Container's set data method within the status image column (see below for my full example). Without this, it does not work. Am I missing something or is there a better way to do this?
Again, thank you very much for your help.
<?xml version="1.0" ?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">
  <mx:Canvas width="100%" height="100%">
    <mx:DataGrid id="myDataGrid" left="0" top="0" bottom="0" right="0"
                 allowMultipleSelection="true" verticalScrollPolicy="on"
                 draggableColumns="false" resizableColumns="false" sortableColumns="false"
                 dataProvider="{myArrayCollection}">
      <mx:columns>
        <mx:DataGridColumn headerText="Name" dataField="name" wordWrap="true" />
        <mx:DataGridColumn headerText="Status" dataField="status" width="75" textAlign="center">
          <mx:itemRenderer>
            <mx:Component>
              <mx:HBox width="100%" height="100%" horizontalAlign="center">
                <mx:Image id="statusImage" width="16" height="16" />
                <mx:Script>
                  <![CDATA[
                  override public function set data(value:Object):void
                    if (value != null)
                      statusImage.source = value.status;
                  ]]>
                </mx:Script>
              </mx:HBox>
            </mx:Component>
          </mx:itemRenderer>
        </mx:DataGridColumn>
      </mx:columns>
    </mx:DataGrid>
  </mx:Canvas>
  <mx:Button id="updateButton" click="updateIcon()" label="Update Icon" />
  <mx:Script>
  <![CDATA[
    import mx.collections.ArrayCollection;
    [Embed(source="assets/success.png")]
    public static const successImage:Class;
    [Embed(source="assets/fail.png")]
    public static const failImage:Class;
    [Embed(source="assets/pending.png")]
    public static const pendingImage:Class;
    [Bindable]
    private var myArrayCollection:ArrayCollection = new ArrayCollection();
    private var lastIndex:Number = 0;
    private function updateIcon():void
      //sample updating
      var item:Object = myArrayCollection.getItemAt(lastIndex);
      (lastIndex % 2 == 0) ? item.status = EmbeddedImages.successImage : item.status = EmbeddedImages.fail1Image;
      myDataGrid.invalidateList();
      if (++lastIndex > myArrayCollection.length - 1)
        lastIndex = 0;
    private function init():void
      //load some dummy sample data for demo/testing
      for (var i:Number = 1; i <= 10; i++)
        myArrayCollection.addItem({
          name:"value-" + i,
          status:pendingImage
    ]]>
    </mx:Script>
</mx:Panel>

Similar Messages

  • How do you set a background image in Pages?

    I have a simple question. How do you set an image to be the background of a Pages '09 document? How do you put a JPG image behind your regular body text? Surely it's possible, but I can't figure out how to do it.

    You just didn't took care to the status of your picture.
    It was an inline one
    Change its status to floating and the menu item is no longer grayed.
    This kind of features are described in Pages User Guide which is also for you
    Yvan KOENIG (VALLAURIS, France) mercredi 13 juillet 2011 22:40:00
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • How can I programmatically change a label?

    Hi everyone,
    I have a 2-D array that I wish to populate with different sorts of data.  Depending upon the data, the names of the rows and columns may change.  Arrays have to have identical labels and I suppose I could simply populate a string indicator, but frankly, that looks like trash.
    How can I programmatically change a label of a column or a row in a 2-D array?  Should I consider using a table?  I want it to look nice.
    Thanks,
    Jason

    Hi
    I do not think you are able to change the label programatically.
    But you might consider to use Captions instead of labels. You can hide labels and make captions visible programatically, and you can change the text of the caption and size (see enclosed vi).
    take care
    Pawel
    Attachments:
    caption.vi ‏20 KB

  • How can you get a mirror image of a photo on iPhoto?

    How can you get a mirror image of a photo on iPhoto?

    By using an external editor. Preview is already on your Mac. It's called 'Flip Horizontal'
    In order of price here are some other suggestions:
    Seashore (free)
    The Gimp (free)
    Graphic Coverter ($45 approx)
    Acorn ($50 approx)
    Pixelmator ($50 approx)
    Photoshop Elements ($75 approx)
    There are many, many other options. Search on MacUpdate or the App Store.
    You can set Photoshop (or any image editor) as an external editor in iPhoto. (Preferences -> General -> Edit Photo: Choose from the Drop Down Menu.) This way, when you double click a pic to edit in iPhoto it will open automatically in Photoshop or your Image Editor, and when you save it it's sent back to iPhoto automatically. This is the only way that edits made in another application will be displayed in iPhoto.

  • What is ChangeWatcher? How do you stop Change Watcher from listening to a propertyChangeEvent?

    What is ChangeWatcher? How do you stop Change Watcher from listening to a propertyChangeEvent?

    ChangeWatcher is a class used to handle the change of a specific property. To stop watching that property, simply call unwatch function as follow:
    var cw:ChangeWatcher = ChangeWatcher.watch( this, "propertyName", changeHandler );
    cw.unwatch();

  • How do you display a new image in  webdynpro view?

    How do you display a new image in  webdynpro view?
    Where is the image stored and how do we specify the image path?

    hi ,
    The UI element Image enables you to integrate graphics into the Web application in a format that is processed by the Web Server u2013 for example, GIF, JPG, and PNG format. Height and width of the graphic can be specified using the properties height and width. The graphic is displayed without borders.
    saveur image   as mime
    with Mime Objects u cn upload doc , jpeg, or giff files from our local system into the webdypnpro system .
    Right click on ur component->mime object->import
    In the transaction sicf/bc/webdynpro , u cn check your component name there you can view the mime objects created by you .
    also refer the SAP online help :
    http://help.sap.com/saphelp_crm50/helpdata/en/46/bb182fab4811d4968100a0c94260a5/content.htm
    to knw more abt mime repositories.
    http://help.sap.com/saphelp_nw04/helpdata/en/f3/1a61a9dc7f2e4199458e964e76b4ba/content.htm
    regards,
    amit

  • How do you weed through duplicate images?

    I love that Aperture allows tasks to be done many different ways. I'd like to hear some ideas on how to do this -
    I am going through and finally getting my old photos from 2002 to current managed in Aperture. Many of the images are a mess on CD backup and more recent images are from the pc (I could get these from an EHD or in iPhoto). Long story short, I have LOTS of duplicate images from one disk to another. I mean the same photo two or three times.
    My library has a top blue folder for the year. The projects within there are almost all by month year (i.e. Apr 2003). As far as I can tell, all of these images are the same - but one project might have an image that another one doesn't have. Should I worry about this or not? I am very detail oriented and anal about it - so set me straight if I need a slap into reality
    Should I just go through my library and view by date and delete the duplicates without regard to which CD they came from? What would you do? How do you weed through duplicate images in this regard?
    I'd love to hear your thoughts!

    I almost thought you hit a winner there... even for general use. I started to read it and realized the import window cannot be resized. Why did I think that? Well, in general, have you ever imported from your camera and then took more pictures? Do you always remember what the last downloaded image was? Wouldn't it be great to resize that import window and see the actual library underneath to check??!
    Anyway, my imports are done so .... last night I did a few months worth and I was in date view within 2003 (not the smart folder at the top under Library) and went through using the 9 key to reject the images that were duplicate. Some of them I could go to the project and reject in larger groups, but mostly it was one by one. It is a painstaking process, but ensures I have every image. Once I know I have it all, I will delete the rejects.
    Keep in mind - my duplicates are not in the same project - they exist in multiple projects, sometimes two or three.
    No other tips out there? I was sure there were enough power users that would have some secret tip to make life easier with Aperture.

  • When making a photo book in Aperture. How do you eliminate having the image numbers under the pictures?

    When making a photo book in Aperture. How do you eliminate having the image numbers under the pictures?

    Click the "Book Actions" cogwheel and select "Page Numbers " -> "Off"
    Regards
    Léonie

  • How do you print multiple different images on a single page in preview

    How do you print multiple different images on a single page in preview?

    Chances are no one who saw your question knew the answer.
    Unless you're willing to share the answer you found here, then anyone else like you searching for the problem who comes across this thread will also be unable to thank you for providing the answer too.  

  • 5.1 SP10 How do you programmatically make a datasource from a dynamically created Pool?

    How do you programmatically make a data source from a dynamically created Pool?
    I can make the Pool OK but can not find any classes the return a datasource
    given a JDBC Pool.
    Thanks in advance

    Hi John,
    weblogic 5.1 doesn't have API allowing dynamic creation
    of datasources. 6.1 does.
    Regards,
    Slava Imeshev
    How do you programmatically make a data source from a dynamically createdPool?
    >
    I can make the Pool OK but can not find any classes the return adatasource
    given a JDBC Pool.
    Thanks in advance

  • How do you save changes made in iPhoto, and export the changed file.  It keeps reverting back to the original.

    How do you save changes made in iPhote, and export the changed picture file? When I select export, current format, it reverts to the original, wiping out all my work.

    Try trash the com.apple.iPhoto.plist file from the HD/Users/ Your Name / library / preferences folder.
    (On 10.7 or later: Hold the option (or alt) key while clicking on the Go menu in Finder to access the User Library)
    (Remember you'll need to reset your User options afterwards. These include minor settings like the window colour and so on. Note: If you've moved your library you'll need to point iPhoto at it again.)
    What's the plist file?
    For new users: Every application on your Mac has an accompanying plist file. It records certain User choices. For instance, in your favourite Word Processor it remembers your choice of Default Font, on your Web Browser is remembers things like your choice of Home Page. It even recalls what windows you had open last if your app allows you to pick up from where you left off last. The iPhoto plist file remembers things like the location of the Library, your choice of background colour, whether you are running a Referenced or Managed Library, what preferences you have for autosplitting events and so on. Trashing the plist file forces the app to generate a new one on the next launch, and this restores things to the Factory Defaults. Hence, if you've changed any of these things you'll need to reset them. If you haven't, then no bother. Trashing the plist file is Mac troubleshooting 101.

  • How do you create a still image from a video using IMovies 11?

    How do you create a still image from a video using IMovies 11 on a Pro Mac?

    The simplest way is to do a simple screen capture.  

  • How do you print a mirror image?

    How do you print a mirror image?

    Or in the elements print window in older versions there's a checkbox right there. in the "improved" print window in recent versions it's under the more options button>printing choices>iron-on transfer>flip image.

  • How do you save a transformed image?

    Windows Store App 8.1.
    I have an image that the user has rotated, scaled and clipped etc.  How do you save the transformed image?
    There are solutions of the forums but these use the System.Media.Imaging library that isn't available, classes like the TransformedBitmap etc. are not available. 
    I'm playing around with this approach but the decoder throws a "The image format is unknown"; 
    imageManipulation is UIElement.Image.
    Any ideas on how to achieve the saving of a Transformed image in a 4.5.1 8.1 store app?
    RenderTargetBitmap rtb = new RenderTargetBitmap();
    await rtb.RenderAsync(imageManipulation, (int)imageManipulation.ActualWidth, (int)imageManipulation.ActualHeight);
    IBuffer buffer = await rtb.GetPixelsAsync();
    using (InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream())
    await ras.WriteAsync(buffer);
    await ras.FlushAsync();
    BitmapDecoder dec = await BitmapDecoder.CreateAsync(BitmapDecoder.BmpDecoderId, ras);
    Rob

    Hi,
    You can use BitmapEncoder to apply transforms such as scaling and cropping, set metadata and properties, and edit pixels while preserving any unedited
    data. After transform the data, you can copy the contents from the in-memory stream to the original file’s stream and close all of the streams. That make you can save the encoded image to the file:
    memStream.Seek(0);
    fileStream.Seek(0);
    fileStream.Size = 0;
    await RandomAccessStream.CopyAsync(memStream, fileStream);
    fileStream.Dispose();
    memStream.Dispose();
    You can see the link to get more information:
    https://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj709937.aspx
    Best Wishes!
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • How do you handle change in user names if folks get married or divorced

    If an application is using the apex authentication scheme, how do you handle change in user names if folks get married or divorced. The reason I ask the question is that all of apex uses v('app_user'), which is the user_name. If I have transactions done by this user and then their name changes, which means so does their id, how do I get all of their transactions, before and after the name change. Traditionally I would expect to use user_id, not sure if this feature is still available. I can always create a custom auth scheme, but that is a lot of additional work. Any ideas?
    Thanks,

    Appreciate your help and time Jari, below is my game plan, unless someone has a better idea,
    I plan on doing the following to use user_id for auditing of transaction records:
    1. Get the user_id to use in the tables audit trail fields
    user_id := apex_util.get_user_id(v('app_user'));
    OR
    user_id := apex_util.get_current_user_id;
    2. If a user changes their name then use
    apex_util.set_last_name(p_user_id, p_new_lastname);
    apex_util.set_username(p_userid, p_new_username);
    Thanks,

Maybe you are looking for

  • Quartz Extreme or video card freezed new iMac every few minutes

    Hi, I recently bought a refurbished iMac because I wanted the ATI video card instead of the new nvidia ones. So it was great, I set it up in less then 5 minutes with zero prior knowledge of macs, and began to do stuff like the commercials, moving vid

  • Best method to seamlessly swap someone's face in a group photo with their face in another photo?

    A band hired me to do a photoshoot of them and it was my first time shooting a band professionally so I was and still am quite nervous about the photos turning out well, especially since they're a well known group and the pictures will be published i

  • Change report process theme v6.0.2

    Wnen we generate a project report, the process is defaulted to "business analyst". How do I change this to be colorBPM? I assume there is a properties file or css for the report generation somewhere but am not sure of the location.

  • Field movement between screen groups in functional location

    Hi, In functional location, we have layout's like 'general', 'organization'. Within these layout's we have screen groups like '020 Location Data' etc. Is it possible to change the field 'catalog profile' out of 'responsibilities' screen group and mov

  • IMac/Yosemite super sluggish

    Thanks in advance to all who read and assist! My system is moving slower and slower these days, especially during Time Machine backups, but also at other times, for reasons I can't figure out.  Here is what EtreCheck says: Problem description: System