PDA

View Full Version : Update handler for button



sharok
Aug 25, 2015, 9:28 AM
Hello. I have the following markup:
...


<ext:Button ID="RefreshDoc" runat="server" Icon="Reload" >
<DirectEvents>
<Click OnEvent="RefreshDocument" Type="Load" Method="POST" Success="doStuffAfterSuccess();">
<ExtraParams>
<ext:Parameter Name="Id" Value="#{Id}.getValue()" Mode="Raw" />
</ExtraParams>
<EventMask ShowMask="true" MinDelay="500" />
</Click>
</DirectEvents>
</ext:Button>

<ext:Button ID="ShowChildButton" runat="server" Icon="ClockGo" Text="Show Child" >
</ext:Button>


This is the RefreshDocument method:


public void RefreshDocument(object sender, DirectEventArgs e)
{
var id = e.ExtraParams.ToDictionary(o => o.Name, v => v.Value).ToGuidId();
if (id == Guid.Empty)
{
this.ShowChildButton.Disabled = true;
return;
}

// skip url building for brevity
this.ShowChildButton.Disabled = false;
this.ShowChildButton.Listeners.Click.Handler ="console.log(1);"

}

As you can see, I send Id, sometimes it can be empty. And when it's empty then button is disabled. After some other actions Id can be filled and when I click `RefreshDoc` button then `ShowChildButton` shows and clickable, but the handler doesn't call.
Where is a problem?

PS. It looks like handler doesn't exist in the response, only disabled/enabled properties (I skipped some strings for brevity):
{script:"Ext.net.ResourceMgr.registerIcon([\"FolderPicture\"]);ShowChildButton.setDisabled(false); ... }

Daniil
Aug 25, 2015, 11:34 AM
Hi @sharok,

Welcome to the Ext.NET forums!

Yes, a Button's Listeners is only taken into account before rendering. If a Button is rendered, it doesn't produce any effect.

Please have a look at this post. There is a few suggestions how to attach listeners on the fly.
http://forums.ext.net/showthread.php?27308&p=121911&viewfull=1#post121911