PDA

View Full Version : [CLOSED] GridCommand Handler



rockhome
Dec 18, 2014, 5:44 AM
This is my test Source,


<ext:CommandColumn ID="CommandColumn1" runat="server" Width="110">
<Commands>
<ext:GridCommand Icon="Delete" CommandName="Delete" Text="Delete"/>
</Commands>
<Listeners>
<Command Handler="Ext.Msg.alert(command, record.data.PCNo);" />
</Listeners>
</ext:CommandColumn>


I wanna use Command Handler to working like below script of OnDiretClick Event.
btnDelete_Click is a code behind command.
for Example


<ext:Button ID="Button4" runat="server" Text="Delete" Icon="Delete" OnDirectClick="btnDelete_Click" />


How to alternate "Ext.Msg.alert(command, record.data.PCNo);" ?

Daniil
Dec 18, 2014, 7:06 AM
Hi @rockhome,

Hope this example helps.

Example

<%@ Page Language="C#" %>

<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"}
};
}
}

protected void CommandColumn_Command(object sender, DirectEventArgs e)
{
X.Msg.Alert(e.ExtraParams["command"], e.ExtraParams["data"]).Show();
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:GridPanel ID="GridPanel1" runat="server">
<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" />
<ext:CommandColumn runat="server">
<Commands>
<ext:GridCommand Icon="Delete" CommandName="Delete" Text="Delete" />
</Commands>
<DirectEvents>
<Command OnEvent="CommandColumn_Command">
<ExtraParams>
<ext:Parameter Name="command" Value="command" Mode="Raw" />
<ext:Parameter Name="data" Value="record.data.test" Mode="Raw" />
</ExtraParams>
</Command>
</DirectEvents>
</ext:CommandColumn>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>

rockhome
Dec 18, 2014, 7:52 AM
It's working well.
Thanks a lot.