As I don’t find the right connection between the CommandName property and the calling of the matching method in the C# CodeBehind, I would love to find what happenes here behind the curtains and who’s firing which event and how the connection appears between those two things.
Here is my sample code:
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:CommandColumn ButtonAlign="Center">
<Commands>
<ext:GridCommand Icon="User" CommandName="SwitchToUserDetail" Text="Details"></ext:GridCommand>
</Commands>
</ext:CommandColumn>
</Columns>
</ColumnModel>
<DirectEvents>
<Command OnEvent="SwitchToUserDetail" >
<ExtraParams>
<ext:Parameter Name="ID" Value="this.selModel.getSelected().data.id" Mode="Raw" />
</ExtraParams>
</Command>
</DirectEvents>
Everything works fine so far, but again, just to clarify and to explain it hopefully a bit better in my bad english:
This attribute
CommandName="SwitchToUserDetail"
Has some connection with my DirectEvent
<Command OnEvent="SwitchToUserDetail" >
<ExtraParams>
<ext:Parameter Name="ID" Value="this.selModel.getSelected().data.id" Mode="Raw" />
</ExtraParams>
</Command>
Which I don’t get cause if I have a look in my CodeBehind where my Method SwitchToUserDetail is defined, I’ll get the object and DirectEventArgs of my DirectEvent while that thing has no more to do with The GridCommand…
Any explanation on this?
Connection between the CommandName and the method in code behind provided by command name value. If you will look in JavaScript code that generated by Ext.NET you will see something like this:
As you see, handler which call your DirectEvent has this arguments: command,record,rowIndex,colIndex. And if you will add new extra parameter “command” to direct event you can make different things accordingly command.
And on server side you can read it as follows: