PDA

View Full Version : [CLOSED] Enable and Disable GridCommand from Click in Button



osef
Feb 21, 2015, 2:06 PM
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

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>

fabricio.murta
Feb 21, 2015, 7:08 PM
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!

osef
Feb 24, 2015, 6:02 PM
thank you so much, it works fine for me