[CLOSED] disable/enable gridcommand

  1. #1

    [CLOSED] disable/enable gridcommand

    Hi

    I have tried many things but I am unable to do the following. this is what I am trying to do.

    I have grid with 3 columns and 2 GridCommands (Upload and View). I would like to disable the View Command if the Filename column is empty.

    
    
    
    <ext:GridPanel ID="grid2" runat="server" Header="false" Frame="true" Visible="true"
    
    
    StoreID="store2" AutoScroll="true">
    
    
    <ColumnModel ID="ColumnModel2" runat="server">
    
    
    <Columns>
    
    
    <ext:Column ColumnID="ArchiveDesc" Header="Description" DataIndex="ArchiveDesc" Width="320"
    
    
    Sortable="true">
    
    
    </ext:Column>
    
    
    <ext:Column ColumnID="Filename" DataIndex="Filename" Header="Filename" Width="280">
    
    
    <%-- <Renderer Fn="change" />--%>
    
    
    
    
    
    </ext:Column>
    
    
    <ext:Column ColumnID="ArchiveID" Header="ArchiveID" DataIndex="ArchiveID" Width="60"
    
    
    Sortable="true">
    
    
    </ext:Column>
    
    
    <ext:CommandColumn Width="90" Header="Actions" ColumnID="CommandButtons">
    
    
    <Commands>
    
    
    <ext:GridCommand Icon="FolderExplore" CommandName="Upload">
    
    
    <ToolTip Text="Upload Document" />
    
    
    </ext:GridCommand>
    
    
    <ext:GridCommand Icon="ApplicationFormMagnify" CommandName="View">
    
    
    <ToolTip Text="View Document" /> 
    
    
    </ext:GridCommand>
    
    
    </Commands> 
    
    
    </ext:CommandColumn>
    
    
    </Columns>
    
    
    </ColumnModel>
    
    
    <SelectionModel>
    
    
    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
    
    
    <AjaxEvents>
    
    
    <RowSelect OnEvent="GridPanel1_RowSelectedChanged">
    
    
    <ExtraParams>
    
    
    <ext:Parameter Name="ArchiveID" Value="this.getSelected().data['ArchiveID']" Mode="Raw" />
    
    
    </ExtraParams>
    
    
    <EventMask ShowMask="false" />
    
    
    </RowSelect>
    
    
    </AjaxEvents>
    
    
    </ext:RowSelectionModel>
    
    
    </SelectionModel>
    
    
    <Listeners>
    
    
    <Command Fn="commandHandler" />
    
    
    </Listeners>
    
    
    <LoadMask ShowMask="true" />
    
    
    <SaveMask ShowMask="true" />
    
    
    <BottomBar>
    
    
    <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="20" StoreID="store2"
    
    
    DisplayInfo="true" AutoWidth="true" />
    
    
    </BottomBar>
    
    
    <Buttons>
    
    
    </Buttons>
    
    
    </ext:GridPanel>
    I have setup the following just to see if it gets called but it is not being called.

    
    
    
    function setButton(grid, command, record, rowIndex) {
    
    
    Ext.Msg.alert(command, record.data.Filename);
    
    
    if (record.data.Filename.length > 0) {
    
    
        //command.iconCls = 'icon-up';
    
    
    
        // ENABLE COMMAND
    }
    
    
    else {
    
    
        // command.iconCls = 'icon-down';
    
    
    
        // DISABLE COMMAND
    }
    
    
    
    
    
    }
    Can you point me in the right direction. thanks
    idriss
  2. #2

    RE: [CLOSED] disable/enable gridcommand

    Hi,

    PrepareCommand is used for Cell commands particular column. For CommandColumn you need to use PrepareToolbar
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Ext.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[]
                {
                    new object[] {"3m Co", true},
                    new object[] {"Alcoa Inc", false},
                    new object[] {"Altria Group Inc", true},
                    new object[] {"American Express Company", false}
                };
    
                this.Store1.DataBind();
            }
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        
        <script type="text/javascript">
            var prepareToolbar = function(grid, toolbar, rowIndex, record){
                toolbar.items.get(0).setDisabled(record.data.disable);
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="company" />
                            <ext:RecordField Name="disable" Type="Boolean" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
            
            <br />
            
            <h3>Icons with tips</h3>
            
            <ext:GridPanel 
                ID="GridPanel1" 
                runat="server" 
                StoreID="Store1" 
                Title="Icons with tips" 
                Width="600" 
                Height="300"
                AutoExpandColumn="Company">
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column ColumnID="Company" Header="Company" Width="160" Sortable="true" DataIndex="company" />
                       <ext:CheckColumn Header="Disable" DataIndex="disable" Editable="true"></ext:CheckColumn>
                        
                        <ext:CommandColumn Width="60">
                            <Commands>
                                <ext:GridCommand Icon="Delete" CommandName="Delete">
                                    <ToolTip Text="Delete" />
                                </ext:GridCommand>
                                <ext:CommandSeparator />
                                <ext:GridCommand Icon="NoteEdit" CommandName="Edit">
                                    <ToolTip Text="Edit" />
                                </ext:GridCommand>
                            </Commands>
                            
                        </ext:CommandColumn>
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>          
           
        </form>
    </body>
    </html>
  3. #3

    RE: [CLOSED] disable/enable gridcommand

    Thank you very much. working nicely.
    idriss

Similar Threads

  1. [CLOSED] How to disable/enable tabs on the client?
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 21, 2012, 5:56 PM
  2. Button Enable/Disable
    By Maia in forum 1.x Help
    Replies: 5
    Last Post: Jul 02, 2010, 8:03 PM
  3. [CLOSED] How to disable/enable all controls in formpanel
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 13, 2009, 12:21 PM
  4. how to disable and enable combobox?
    By sadeque in forum 1.x Help
    Replies: 1
    Last Post: Jul 27, 2009, 5:00 AM
  5. Enable or disable the button
    By VietView in forum 1.x Help
    Replies: 4
    Last Post: Jan 09, 2009, 11:59 AM

Posting Permissions