Displaying an Image/Icon inside an EXT.NET GridPanel Cell with value (depinding on value)

  1. #1

    Displaying an Image/Icon inside an EXT.NET GridPanel Cell with value (depinding on value)

    Greetings forumnites,

    I have a question regarding rendering an Icon in a cell depending on the value.
    The value comes from the datatable. The value can either be a string ?good? or ?bad? and resides in the column ?Status?.

    Layout:

    <ext:GridPanel ID="grid" runat="server">
    <Store>
       <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="status" Mapping="Status" />
                                <Renderer Handler = "imgRenderer()" />  
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
        </Store>
     <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:Column DataIndex="status" Header="Status" Width="160">
                </ext:Column> 
            </Columns>
    </ColumnModel>
    </ext:GridPanel>
    I tried something like this, with no avail:

    <script type="text/javascript">
        function imgRenderer(value, meta, record, rowIndex, colIndex, store) {
    if(data == ?good?)
    {
    return "<img src='accept.png'/>"
    }
    else (data == "bad") 
            {
                return "<img src='cancel.png'/>"
            }
        }
    </script>
    I am new to this, I googled for some examples but it doesn't really fit into mine implementation.
    For example: http://miamicoder.com/2009/displayin...l-cell-part-2/
    Last edited by Daniil; Feb 06, 2012 at 12:23 PM. Reason: Please use [CODE] tags
  2. #2
    Hi,

    Renderer should return a string value.

    Example
    <Renderer Handler = "return imgRenderer();" />
    See also
    http://forums.ext.net/showthread.php?13336
  3. #3
    Ah missing return, silly me xD

    I have the icons I need now, but there one little hickup.

    I can't see my values anymore. The icons accept and cancel is on top of my values 'good' and 'bad' I think...

    Is there a way to manipulate the statement return "<img src='accept.png'/>" ? Like adding 'right no-repeat' property?
  4. #4
    You can set up the CSS "class" attribute as for a common HTML element.
    http://www.w3schools.com/tags/tag_img.asp
  5. #5
    Thank you, I will look into it :)
    [Closed] ?
  6. #6
    Quote Originally Posted by HaamSapTjai View Post
    [Closed] ?
    Don't worry, we mark the threads as closed only on the premium forums.

Similar Threads

  1. [CLOSED] GridPanel custom render cell with icon
    By smart+ in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 28, 2010, 6:39 PM
  2. gridpanel: change icon in a cell
    By maxdiable in forum 1.x Help
    Replies: 0
    Last Post: Aug 07, 2010, 8:51 AM
  3. Replies: 0
    Last Post: Sep 24, 2009, 5:56 AM
  4. Replies: 1
    Last Post: Jun 02, 2009, 12:23 PM
  5. change image in cell gridpanel
    By maxdiable in forum 1.x Help
    Replies: 5
    Last Post: May 25, 2009, 3:58 PM

Tags for this Thread

Posting Permissions