PDA

View Full Version : [CLOSED] Set directevents to a column in code behind



Antonio09
Aug 22, 2012, 6:15 PM
Hi,

I'm creating a gridpanel dinamically, I'm putting an ImageCommand on some columns like this (VB .NET):


Dim col As New Column
col.ID = "someID"
col.Text = "some text"
col.Width = "120"
col.DataIndex = "data"

Dim btn As New ImageCommand
btn .CommandName = "ok"
btn .Icon = Icon.Accept
btn .Text = "OK"

col.Commands.Add(btn)

Now, I'm trying to set the command event handler but I can't find the way, this doesn't work:


col.DirectEvents.Command.DirectEventHandler = New ComponentDirectEvent.DirectEventHandler(AddressOf Calculate_Click)

I need to fire a server side event when the ImageCommand is clicked, with sending some parameters, How can I achive this?

thank you.

Antonio09
Aug 23, 2012, 1:03 AM
Now, I'm trying to set the command event handler but I can't find the way, this doesn't work:


col.DirectEvents.Command.DirectEventHandler = New ComponentDirectEvent.DirectEventHandler(AddressOf Calculate_Click)

I need to fire a server side event when the ImageCommand is clicked, with sending some parameters, How can I achive this?


I found the way of set the handler:


AddHandler col.DirectEvents.Command.Event, AddressOf Calculate_Click

But now, when I click the button I get an error status code 500: The control with ID 'myColID' not found.

Please, How can i solve it?

Daniil
Aug 23, 2012, 4:58 AM
Hi,

Neither ASP.NET or Ext.NET doesn't recreate dynamic controls automatically.

But DirectEvent requires a control instance.

You should recreate the controls manually or use DirectMethods instead of DirectEvents. Though, please note that DirectMethods defined in some user control also requires this user control instance.

Antonio09
Aug 23, 2012, 3:22 PM
Thank you Daniil, DirectMethods works good to catch the command event server side, but I need to send some cell data as parameters, Is it possible to do that with DirectMethods?


col.Listeners.Command.Handler = "App.direct.Calculate_Click()"
...

<DirectMethod()>
Public Sub Calculate_Click()
'Get grid, command, record, row, col, value..
End Sub

Daniil
Aug 23, 2012, 4:36 PM
Yes, it is possible. Please see #3:
http://examples2.ext.net/#/Events/DirectMethods/Overview/