[CLOSED] Gridcommand replace Icon and disable command

  1. #1

    [CLOSED] Gridcommand replace Icon and disable command

    Hi,

    I have an imagecommandcolum with a directevent on the grid.
    If the directevent is fired I need to update the commandimage and disable the command. How can I do that.


                        <ext:ImageCommandColumn ID="colOrderFinished" runat="server" Width="30">
                            <Commands>
                                <ext:ImageCommand Icon="SportGolfPractice" CommandName="cmdDocumentsChecedTrue" Hidden="false" IconCls="">
                                </ext:ImageCommand>
                                <ext:ImageCommand Icon="SportGolf" CommandName="cmdDocumentsChecedFalse" Hidden="true">
                                </ext:ImageCommand>
                            </Commands>
                            <DirectEvents>
                                <Command OnEvent="cmdOrderFinished">
                                    <ExtraParams>
                                    </ExtraParams>
                                </Command>
                            </DirectEvents>
                            <Listeners>
                                <command Handler="finishOrder(record, command);" />
                            </Listeners>
                        </ext:ImageCommandColumn>
    I tried something like that, but now the direktevent fires doesn't fires anymore
    and the icon don't changed.


     function finishOrder(record, command) {
                column.commands(0).hidden = true;
              
                debugger;
                if (command.command == 'cmdDocumentsChecedTrue') {
                    command.hidden = true;
                }
                if (command.command == 'cmdDocumentsChecedFalse') {
                    command.hidden = false;
                }
                record.disableCommand = true;
                //this.view.refreshRow(this.store.indexOf(record));
                // GridPanel1.getView().refresh()
            }
    Thanks for help.
    Last edited by Daniil; Apr 24, 2013 at 1:05 PM. Reason: [CLOSED]
  2. #2
    Hi @sisa,

    Please take a look at the example.

    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", "test2", "test3" },
                    new object[] { "test4", "test5", "test6" },
                    new object[] { "test7", "test8", "test9" }
                };
                store.DataBind();
            }
        }
     
        protected void OnCommand(object sender, DirectEventArgs e)
        {
            System.Threading.Thread.Sleep(3000);
            X.Msg.Alert("onCommand", "Hello from Server!").Show();
        }
    </script>
     
    <!DOCTYPE html>
     
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
     
        <script>
            var prepareCommand = function (grid, command, record, row) {
                if (command.command === "test") {
                    if (record.data.commandDisabled) {
                        command.disabled = true;
                    }
                     
                    if (record.data.commandIcon) {
                        command.iconCls = record.data.commandIcon;
                    }
                }            
            };
     
            var onCommand = function (column, command, record, recordIndex, cellIndex) {
                var view = column.grid.getView();
     
                record.data.commandDisabled = true;
                record.data.commandIcon = Ext.net.ResourceMgr.getIcon("Add");
     
                view.recordToUpdateAfterDirectEvent = record;
                view.indexToUpdateAfterDirectEvent = recordIndex;
                view.refreshNode(recordIndex);
            };
     
            var onDirectEventComplete = function () {
                var view = App.GridPanel1.getView(),
                    record = view.recordToUpdateAfterDirectEvent,
                    index = view.indexToUpdateAfterDirectEvent;
     
                record.data.commandDisabled = false;
                record.data.commandIcon = false;
     
                view.refreshNode(index);
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            <ext:GridPanel ID="GridPanel1" runat="server">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="test1" />
                                    <ext:ModelField Name="test2" />
                                    <ext:ModelField Name="test3" />
                                    <ext:ModelField Name="commandDisabled" Type="Boolean" />
                                    <ext:ModelField Name="commandIcon" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test1" DataIndex="test1" />
                        <ext:Column runat="server" Text="Test2" DataIndex="test2" />
                        <ext:Column runat="server" Text="Test3" DataIndex="test3" />
                        <ext:ImageCommandColumn runat="server">
                            <Commands>
                                <ext:ImageCommand CommandName="test" Icon="Accept" />
                            </Commands>
                            <PrepareCommand Fn="prepareCommand" />
                            <Listeners>
                                <Command Fn="onCommand" />
                            </Listeners>
                            <DirectEvents>
                                <Command OnEvent="OnCommand" Complete="onDirectEventComplete" />
                            </DirectEvents>
                        </ext:ImageCommandColumn>
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>
    Last edited by Daniil; Apr 22, 2013 at 7:35 AM.
  3. #3
    After updating from SVN you will be able to replace
    record.data.commandIcon = Ext.net.ResourceMgr.getIcon("Add");
    with
    record.data.commandIcon = "#Add";
  4. #4
    Quote Originally Posted by Daniil View Post
    After updating from SVN you will be able to replace
    record.data.commandIcon = Ext.net.ResourceMgr.getIcon("Add");
    with
    record.data.commandIcon = "#Add";


    thanks, it works

Similar Threads

  1. Replies: 7
    Last Post: Jun 17, 2014, 10:14 AM
  2. Replies: 6
    Last Post: Apr 16, 2013, 1:43 PM
  3. Replies: 0
    Last Post: May 03, 2012, 2:21 AM
  4. Replies: 1
    Last Post: Apr 11, 2012, 12:52 PM
  5. [CLOSED] disable/enable gridcommand
    By idrissb in forum 1.x Premium Help
    Replies: 2
    Last Post: Sep 03, 2009, 2:25 PM

Posting Permissions