Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 911711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:15:25+00:00 2026-05-15T17:15:25+00:00

I’m attempting to add an image to a datagrid item render dynamically in flex.

  • 0

I’m attempting to add an image to a datagrid item render dynamically in flex.

Here is my DataGrid code

The value of “str” in the getImagePath function is correct.

<?xml version="1.0" encoding="utf-8"?>
<mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml"
             doubleClickEnabled="true">
    <mx:Script>
        <![CDATA[
            private function userLabelFunction(item:Object, column:DataGridColumn):String
            {
                return item.user.username;
            }

            private function getImagePath(item:Object, column:DataGridColumn):String
            {
                var str:String=item.track["artwork-url"]

                if (str == "")
                {
                    str=item.user["avatar-url"];
                }

                return str;

            }
        ]]>
    </mx:Script>
    <mx:columns>
        <mx:DataGridColumn dataField="artwork-url"
                           headerText="Art"
                           itemRenderer="components.content.contents.datagrids.ImageRenderer"
                           labelFunction="getImagePath"/>
        <mx:DataGridColumn dataField="title"
                           headerText="Title"
                           minWidth="100"/>
        <mx:DataGridColumn dataField="user"
                           headerText="User"
                           labelFunction="userLabelFunction"/>
        <mx:DataGridColumn dataField="bpm"
                           headerText="BPM"/>
    </mx:columns>
</mx:DataGrid>

I cant manage to get that image url value into my item renderer

I’ve tried overriding the set data property like so

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
         height="60"
         verticalAlign="top"
         creationComplete="init()">
    <mx:Script>
        <![CDATA[
            import components.content.contents.containers.ContentContainerSoundCloud;
            import mx.core.Application;
            import mx.controls.dataGridClasses.DataGridColumn;
            import com.adobe.viewsource.ViewSource;

            [Bindable]
            public var imgPath:String;

            private function init():void
            {

            }
            override public function set data(value:Object):void
                    {
                        super.data = value.track["artwork-url"];

                        imgPath =super.data.valueOf()
                        trace(imgPath)

                    }
        ]]>
    </mx:Script>

    <mx:Image source="{imgPath}" id="rowimage"/>
</mx:HBox>

But in doing so the trace output looks like so

<artwork-url>
  <mx_internal_uid>7C98E149-1984-584C-7600-AD8940BF2A9C</mx_internal_uid>
</artwork-url>

I was expecting the “value” property in the set data to recieve the string I sent it from the get imagePathFunction but it fact it returns my entire XMLList.

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:15:26+00:00Added an answer on May 15, 2026 at 5:15 pm

    Based on your trace output it looks like you are retrieving the wrong value from your dataProvider to set as the source. Without seeing your actual data, it’s hard to know what the exact issue may be.

    That said, I would re-work your itemRenderer a bit. First, you don’t need to put a single image in an HBox. Just use an Image. Also, you should not need to specify the height in the Renderer, the DataGrid should take care of such positioning.

    I also removed the creationComplete listener, since no code was in it. And instead of using binding, I just set the soruce property on the component in the data set method. I also set the super.data to the value, not a processed value; and I performed the processing when setting the value’s source. The updated code is like this:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Image xmlns:mx="http://www.adobe.com/2006/mxml"
             >
        <mx:Script>
            <![CDATA[
                import components.content.contents.containers.ContentContainerSoundCloud;
                import mx.core.Application;
                import mx.controls.dataGridClasses.DataGridColumn;
                import com.adobe.viewsource.ViewSource;
    
                [Bindable]
                public var imgPath:String;
    
                override public function set data(value:Object):void
                        {
                            super.data = value;
    
                            this.source =value.track["artwork-url"];
                            trace(imgPath)
    
                        }
            ]]>
        </mx:Script>
    
    </mx:Image>
    

    My preferred method in itemRenderers is to listen to the dataChange event, however that’s just personal preference. There is nothing wrong w/ overriding the data set method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.