[CLOSED] Change a ImageCommands Icon with JS

  1. #1

    [CLOSED] Change a ImageCommands Icon with JS

    Hi

    I have to modify a Image Commands Icon based on a Value I the Grid.

    Here's a part of the Grid Markup :

                        <ext:Column ColumnID="colHasOrder" DataIndex="HasOrder" Header="<%$ Resources:CUSTRocheImport, HasOrder %>" Width="150" Editable="False" Hidden="true" Groupable="true" Sortable="true" MenuDisabled="False" />
    
                        <ext:ImageCommandColumn Width="25">
                            <Commands>
                                <ext:ImageCommand Icon="CartMagnify " CommandName="cmdShowOrder">
                                    <ToolTip Text="<%$ Resources:CUSTRocheImport, ShowOrder %>" />
                                </ext:ImageCommand>     
                                
                            </Commands>         
                            <PrepareCommand Fn="showHasOrderLink" />
                        </ext:ImageCommandColumn>
    In case of 'HasOrder' the Image Command Icon should be 'CardMagnify' else 'Error'. The HasOrder Field is boolean.

    I tried this but it doesn work (no icon is shown)

    var showHasOrderLink = function (grid, command, record, row) {
        {
                     alert(record.get('HasOrder'));
    
            if (record.get('HasOrder') == true) {
                command.iconCls = "CartMagnify";
            } else {
                command.iconCls = "Error";
            }
        }
    };
    Any Idea ?

    Peter
    Last edited by Daniil; Sep 18, 2012 at 12:24 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please replace
    command.iconCls = "CartMagnify";
    with
    command.iconCls = "icon-cartmagnify";
    and
    command.iconCls = "Error";
    with
    command.iconCls = "icon-error";
    To easily know the class names of Icons, please use:
    ResourceManager.GetIconClassName(Icon.CartMagnify)
    Also you might need to register these icons manually, if they are not explicitly used in the markup or code behind. It the last case the icons are registered automatically.
    this.ResourceManager1.RegisterIcon(Icon.Error);

Similar Threads

  1. Comfirmations on ImageCommands
    By Spamme in forum 1.x Help
    Replies: 0
    Last Post: Sep 03, 2012, 8:38 AM
  2. Dynamically-added ImageCommands and DirectEvents
    By Skizzot223 in forum 1.x Help
    Replies: 1
    Last Post: Mar 29, 2012, 9:23 PM
  3. gridpanel: change icon in a cell
    By maxdiable in forum 1.x Help
    Replies: 0
    Last Post: Aug 07, 2010, 8:51 AM
  4. Can I change MenuItem's Icon dynamic .
    By Tom Zhang in forum 1.x Help
    Replies: 1
    Last Post: Jun 23, 2009, 11:16 AM
  5. Can I change MenuItem's Icon dynamic .
    By Tom Zhang in forum 1.x Help
    Replies: 2
    Last Post: Jun 23, 2009, 5:58 AM

Posting Permissions