PDA

View Full Version : [CLOSED] global function call after render



RCM
Oct 03, 2013, 8:57 PM
Hi, Is is possible to define a global function that must always be called on after render of window. This is to avoid setting the function individually on the after render event of each window.

Baidaly
Oct 03, 2013, 10:27 PM
Hello!

You can use createSequence and prototype to add another method that will be called after original afterRender method.


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

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head runat="server">
</head>
<body>
<ext:ResourceManager runat="server" />

<script>
Ext.window.Window.prototype.afterRender = Ext.Function.createSequence(Ext.window.Window.prot otype.afterRender, function () {
console.log(this.id + ' rendered');
});
</script>

<ext:Window runat="server" ID="Window1" Title="Some window" Width="300" Height="300" Hidden="True"></ext:Window>

<ext:Window runat="server" ID="Window2" Title="Another window" Width="300" Height="300" Hidden="True"></ext:Window>
</body>
</html>

Daniil
Oct 04, 2013, 4:42 AM
Hi everybody,

Here is a bit different way to get it. Not better, just an alternative.

Example

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

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script>
Ext.window.Window.override({
afterRender: function() {
this.callParent();
console.log(this.id + ' rendered');
}
});
</script>
</head>
<body>
<ext:ResourceManager runat="server" />

<ext:Window ID="Window1" runat="server" />

<ext:Window ID="Window2" runat="server" />
</body>
</html>

Please note that the afterRender method is a template one and supposed to be overridden.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.Component-method-afterRender