[CLOSED] Enable and Disable GridCommand from Click in Button

  1. #1

    [CLOSED] Enable and Disable GridCommand from Click in Button

    Hi, I have a issue with the GridCommand on the GridPanel

    I have a GridPanel, and I have one Column with 2 Command, but I need only work with one of those, for example, if I Press the first button(Disabled Comman1), this disable all first command, and if I press the second Button (Enabled Command 1), this will be enable only the first command too, do you can give me some suggestions? Thanks

    Click image for larger version. 

Name:	Captura.PNG 
Views:	1 
Size:	20.7 KB 
ID:	21781

    <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                List<Pruebas> lPruebas = new List<Pruebas>();
    
                for (int i = 0; i < 5; i++)
                {
                    Pruebas oPruebas = new Pruebas();
                    oPruebas.Column1 = "Columna1" + i;
                    oPruebas.Column2 = "Columna2" + i;
                    lPruebas.Add(oPruebas);
                }
    
                sDefault.DataSource = lPruebas;
                sDefault.DataBind();
            }
    
            public class Pruebas
            {
                string column1;
                string column2;
    
                public string Column1 { set { column1 = value; } get { return column1; } }
                public string Column2 { set { column2 = value; } get { return column2; } }
            }
    
    </script>
    
            <ext:ResourceManager ID="rmDefault" runat="server" HideInDesign="true" />
    
            <ext:GridPanel
                ID="gpDefault"
                runat="server"
                Height="200"
                Width="303">
                <Store>
                    <ext:Store ID="sDefault" runat="server">
                        <Model>
                            <ext:Model ID="mDefault" runat="server">
                                <Fields>
                                    <ext:ModelField Name="Column1" Type="String" />
                                    <ext:ModelField Name="Column2" Type="String" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <TopBar>
                    <ext:Toolbar ID="tbDefault" runat="server">
                        <Items>
                            <ext:Button ID="btnEnable" Text="Disable Command 1" runat="server">
                                <Listeners>
                                    <Click Handler="" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="btnDisable" Text="Enable Command 1" runat="server">
                                <Listeners>
                                    <Click Handler="" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel>
                    <Columns>
                        <ext:Column ID="cColumna1" runat="server" DataIndex="Column1" Text="Column1" />
                        <ext:Column ID="cColumna2" runat="server" DataIndex="Column2" Text="Column2" />
                        <ext:CommandColumn
                            ID="ccPrueba"
                            runat="server">
                            <Commands>
                                <ext:GridCommand CommandName="Test1" Icon="Accept" />
                                <ext:GridCommand CommandName="Test2" Icon="Add" />
                            </Commands>
                        </ext:CommandColumn>
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
    Last edited by fabricio.murta; Feb 24, 2015 at 7:37 PM. Reason: [CLOSED]
  2. #2
    Hello @osef,

    I tried to find a way to selectively sweep the store disabling the buttons, but this seems not possible, or not trivial.

    But as for your main goal, I believe this is sufficient.

    Add this javascript to enable/disable the buttons:
                    function enableAllFirst() {
                        App.ccPrueba.commands[0].disabled = false;
                        App.gpDefault.reconfigure();
                    }
                    function disableAllFirst() {
                        App.ccPrueba.commands[0].disabled = true;
                        App.gpDefault.reconfigure();
                    }
    And then call them from the respective handlers you left empty on your code (lines 53 and 58).

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    thank you so much, it works fine for me

Similar Threads

  1. [CLOSED] Disable GridCommand of a gridPanel on Command Click
    By otouri in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Apr 16, 2013, 1:43 PM
  2. [CLOSED] Enable/Disable Button
    By FVNoel in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Mar 19, 2013, 12:02 PM
  3. Replies: 1
    Last Post: Jul 28, 2011, 4:25 PM
  4. Button Enable/Disable
    By Maia in forum 1.x Help
    Replies: 5
    Last Post: Jul 02, 2010, 8:03 PM
  5. [CLOSED] disable/enable gridcommand
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 03, 2009, 2:25 PM

Tags for this Thread

Posting Permissions