[CLOSED] How to display an image in GridPanel column?

  1. #1

    [CLOSED] How to display an image in GridPanel column?

    Hi,

    I need to render different icons in a GridPanel column depending on the value of the row record. What would be the best approach to achieve it? I believe that can be done in the Renderer JS function but I need to provide the correct path in JS to the icons in the resource file. Please advise.

    Thanks,

    Vadym
    Last edited by Daniil; Feb 28, 2012 at 1:19 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Yes, you'll need to us a Column Renderer and return the html required to render the image file.

    You can find the path to the Icons within your project by running the following

    Example

    this.ResourceManager1.GetIconUrl(Icon.Accept);
    This will return a string path to the Icon.Accept, which you can modify to return any Icon image.

    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    Thanks for your help Geoffrey!

    Here's what eventually worked for me:

    <script type="text/javascript">
            var iconRenderer = function (value, metadata, record) {
                if (record.get("RowIcon") !="") {
                    value = String.format("<img width='80%' height='80%' src='{0}' />", Ext.net.ResourceMgr.getIconUrl(record.get("RowIcon")));
                }
                return value;
            };
    </script>
    <ext:Column ColumnID="RowIcon" Header="" DataIndex="RowIcon" Width="24">
         <Renderer Fn="iconRenderer" />
    </ext:Column>
    I think there may be a way to accomplish the same on the server. I'd be curious to learn if it is indeed possible.

    Thanks,

    Vadym
  4. #4
    Quote Originally Posted by vadym.f View Post
    I think there may be a way to accomplish the same on the server. I'd be curious to learn if it is indeed possible.
    Well, not sure what exactly you'd like to accomplish on server side.

    Just to clarify:
    http://forums.ext.net/showthread.php...ll=1#post71828
  5. #5
    Quote Originally Posted by Daniil View Post
    Well, not sure what exactly you'd like to accomplish on server side.

    Just to clarify:
    http://forums.ext.net/showthread.php...ll=1#post71828
    I was just curious if rendering images in the GridPlanel columns was available on the server. I think TemplateColumn can be used but not quite sure. Anyway, I got the code that does the job for me.

    Thanks,

    Vadym
  6. #6
    Generally, yes, you could set up Template for a TemplateColumn on server side using:
    <img src="{RowIcon}" />
    Though, personally, I'd prefer to use a custom Renderer.
  7. #7
    Quote Originally Posted by Daniil View Post
    Generally, yes, you could set up Template for a TemplateColumn on server side using:
    <img src="{RowIcon}" />
    Though, personally, I'd prefer to use a custom Renderer.
    Thanks Daniil!

    Vadym

Similar Threads

  1. Display image in GridPanel AND FormPanel
    By nazmulrockon in forum 2.x Help
    Replies: 4
    Last Post: May 09, 2014, 2:32 AM
  2. [CLOSED] How to set an image into GridPanel column on the client?
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 19, 2012, 4:55 PM
  3. how to hide/display CheckboxSelection column in GridPanel.
    By Satyanarayana murthy in forum 1.x Help
    Replies: 2
    Last Post: Feb 26, 2010, 9:07 AM
  4. [CLOSED] GridPanel: display a Column as a TextArea
    By pschojer in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 16, 2009, 7:51 AM
  5. Image and Text column in gridpanel
    By filipator in forum 1.x Help
    Replies: 0
    Last Post: Mar 16, 2009, 2:48 PM

Posting Permissions