[CLOSED] Grid row - visible show icons

  1. #1

    [CLOSED] Grid row - visible show icons

    Hi,

    based on this example https://examples2.ext.net/#/GridPane...pare_Commands/
    i implemented some funtionalities in my grid.

    Issue: On the fly based on some flag i am changing icons in grid rows. But it is not working.


    
    Ext.Net.ResourceManager ResourceManager1 = new Ext.Net.ResourceManager();
        ResourceManager1.RegisterIcon(Ext.Net.Icon.MoneyAdd);
    
    Ext.Net.ImageCommand workflowgo = new Ext.Net.ImageCommand();
        workflowgo.CommandName = "prodworkflow";
        workflowgo.Icon = Ext.Net.Icon.BulletCross;
     columnModel.Columns.Add(Html.X().Column()
                                                        .Text(" ")
                                                        .Sortable(false)
                                                        .Width(50)
                                                        .MenuDisabled(true)
                                                        .Commands(cmd =>
                                                        {
                                                            cmd.Add(workflowgo);
                                                        }).PrepareCommands(pcmd => pcmd.Fn = "prodprepareCommand").Listeners(gridlisteners =>
                                                        {
                                                            gridlisteners.Command.Fn = "onCommand";
                                                        })
                                                        );
    var prodprepareCommand = function (grid, commands, record, row, col, value) {
    
            if (record.data.JobStatusId == "5" || record.data.JobStatusId == "6" || record.data.JobStatusId == "7" || record.data.JobStatusId == "8" || record.data.JobStatusId == "9" || record.data.JobStatusId == "10") {
                commands.push({
                    iconCls: "icon-moneyadd",
                    command: "moneyadd"
                });
            }
    
        };
    newly added icon is invisible in grid.

    Do the needful.
    Thanks in advance.
    Last edited by Daniil; Sep 28, 2012 at 2:46 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I am unable to reproduce.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "test1" },
                    new object[] { "test2" }
                };
                store.DataBind();
                
                this.ResourceManager1.RegisterIcon(Ext.Net.Icon.MoneyAdd);
            }
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script type="text/javascript">
            var prepareCommands = function (grid, commands, record, row, col, value) {
                commands.push({
                    iconCls : "icon-moneyadd",
                    command : "moneyadd"
                });
            };
        </script>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Model>
                        <ext:Model runat="server">
                            <Fields>
                                <ext:ModelField Name="test" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column runat="server" Text="Test" DataIndex="test">
                        <Commands>
                            <ext:ImageCommand CommandName="Accept" Icon="Accept" />
                        </Commands>
                        <PrepareCommands Fn="prepareCommands" />
                    </ext:Column>
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
    </body>
    </html>
    I would ensure this code
    commands.push({
        iconCls : "icon-moneyadd",
        command : "moneyadd"
    });
    is actually executed.

    Can you see the resource request for "MoneyAdd" icon? Is it actually loaded?

    If the issue persists, please provide a full sample to reproduce the problem.
  3. #3
    _ExtLayoutOther.cshtml (Layout Page)

    
    @using Ext.Net.MVC
    <!DOCTYPE html>
    <html>
    <head>
        @Html.X().ResourcePlaceHolder(Ext.Net.ResourceMode.ScriptFiles)
        <script type="text/javascript" src="@Url.Content("~/scripts/json2.js")" ></script>
        <script src="@Url.Content("~/Scripts/jquery-1.5.1.js")" type="text/javascript"></script>
        <script type="text/javascript" src="@Url.Content("~/Scripts/extTab.js")"></script>
        
         <script language="javascript" type="text/javascript">
             $(function () {
                 setTimeout(function () {
                     if ($("#unlicensed").size() > 0) {
                         $("#popaction").remove();
                         $("#unlicensed").remove();
                     }
                 }, 2000);
             });
        </script>
    </head>
    <body>
        <div>
            @Html.X().ResourceManager()
            @RenderBody()
            <iframe frameborder="0" height="0" width="0" scrolling="no" src="@Url.Content("~/Home/GetAlerts")">
            </iframe>
    
        </div>
    </body>
    </html>
    Grid Page

    @using Ext.Net.MVC
    @{
        Layout = "~/Views/Shared/_ExtLayoutOther.cshtml";            
    }
    <script type="text/javascript" language="javascript">
        var prepareCommand = function (grid, commands, record, row, col, value) {
            if (record.data.Id == "949") {
                commands.push({
                    iconCls: "icon-moneyadd",
                    command: "moneyadd"
                });
            }
        };
    </script>
    @{
        Ext.Net.ResourceManager ResourceManager1 = new Ext.Net.ResourceManager();
        ResourceManager1.RegisterIcon(Ext.Net.Icon.MoneyAdd);
    
        Ext.Net.ImageCommand imageco = new Ext.Net.ImageCommand();
        imageco.CommandName = "executingsite";
        imageco.Icon = Ext.Net.Icon.PageWhiteGo;
        imageco.ToolTip.Text = "Executing in Different Site";
    }
    @(
     Html.X().Viewport()
            .Layout("fit")
            .Items(viewportitemsfit =>
                {
                    viewportitemsfit.Add(
                        Html.X().GridPanel()
                        .ID("extgrid")
                        .Store(storeitem =>
                        {
                            storeitem.Add(
                                Html.X().Store()
                                .AutoLoad(true)
                                 .Proxy(proxy => proxy.Add(Html.X().AjaxProxy()
                                                                            .Url(Url.Content(string.Format("~/Dashboard/GetExtClientWorkListDashboardAll/?JobStatus={0}", 5)))
                                                                            .Reader(reader => reader.Add(Html.X().JsonReader()
                                                                            .Root("data")
                                                                        ))
                                                                ))
                                .Model(model => model.Add(Html.X().Model()
                                    .IDProperty("Id")
                                                                        .Fields(fields =>
                                                                        {
                                                                            fields.Add(Html.X().ModelField().Name("Id"));
                                                                        })
                                    ))
                                );
                        })
                         .ColumnModel(columnModel =>
                                                {
                                                    columnModel.Columns.Add(Html.X().Column()
                                                        .Text("&nbsp;")
                                                        .Sortable(false)
                                                        .Fixed(true)
                                                        .Width(80)
                                                        .MenuDisabled(true)
                                                        .Commands(cmd =>
                                                        {
                                                            cmd.Add(imageco);
                                                        })
                                                        .PrepareCommands(pcmd => pcmd.Fn = "prepareCommand")
                                                    );
                                                    columnModel.Columns.Add(Html.X().Column()
                                                    .Text("Job ID")
                                                    .Sortable(true)
                                                    .Flex(1)
                                                    .DataIndex("Id")
                                                    .Groupable(false)
                                                );
                                                })
                        );
                })
    )
  4. #4
    You should use the page ResourceManager here:
    Ext.Net.ResourceManager ResourceManager1 = new Ext.Net.ResourceManager();
    ResourceManager1.RegisterIcon(Ext.Net.Icon.MoneyAdd);
    not just a new instance.

    So, please replace with
    Ext.Net.ResourceManager.GetInstance().RegisterIcon(Ext.Net.Icon.MoneyAdd);
  5. #5
    Quote Originally Posted by Daniil View Post
    You should use the page ResourceManager here:
    Ext.Net.ResourceManager ResourceManager1 = new Ext.Net.ResourceManager();
    ResourceManager1.RegisterIcon(Ext.Net.Icon.MoneyAdd);
    not just a new instance.

    So, please replace with
    Ext.Net.ResourceManager.GetInstance().RegisterIcon(Ext.Net.Icon.MoneyAdd);
    I replaced your code but it is giving error like
    Object reference not set to an instance of an object.
    Ext.Net.ResourceManger.GetInstance() returns null.
  6. #6
    My fault, the GetInstance method doesn't work under Razor.

    For now, please use:
    X.Js.Call("Ext.net.ResourceMgr.registerIcon", "MoneyAdd");
    to register the icon.

    We will improve that in v2.1.

    Thanks for the question.
  7. #7
    Quote Originally Posted by Daniil View Post
    My fault, the GetInstance method doesn't work under Razor.

    For now, please use:
    X.Js.Call("Ext.net.ResourceMgr.registerIcon", "MoneyAdd");
    to register the icon.

    We will improve that in v2.1.

    Thanks for the question.
    It's working fine.

    Thanks for your update.
  8. #8
    Quote Originally Posted by Daniil View Post
    My fault, the GetInstance method doesn't work under Razor.

    For now, please use:
    X.Js.Call("Ext.net.ResourceMgr.registerIcon", "MoneyAdd");
    to register the icon.

    We will improve that in v2.1.

    Thanks for the question.
    Now you can use:
    @{
        MvcResourceManager.RegisterGlobalIcon(Icon.MoneyAdd);
    }

Similar Threads

  1. [CLOSED] How to show a not visible combobox by Ajax
    By Oliver in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 02, 2012, 7:54 PM
  2. [CLOSED] Icons don't show [Razor]
    By boris in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Apr 25, 2012, 2:38 PM
  3. Replies: 5
    Last Post: Jul 22, 2011, 7:41 AM
  4. [CLOSED] Triggerfield icons don't show
    By SFritsche in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Feb 02, 2010, 3:55 PM
  5. icons dont show
    By tonymayoral in forum 1.x Help
    Replies: 3
    Last Post: May 23, 2009, 9:59 PM

Posting Permissions