PDA

View Full Version : [CLOSED] [#645] v.3 Window in Bin tag - cannot be reached on client by App.WindowName



omazlov
Dec 30, 2014, 2:27 PM
Hi EXT.NET Team,

If Bin tag contains Window it could not been reached in Java-script using App.WindowName.
In v.2.5 it was fine

I do not know may be it is a new rule..

Thanks,
Oleg

RaphaelSaldanha
Dec 30, 2014, 8:58 PM
On the following example, _pnl is defined but _wdn is undefined. I'm gonna investigate it


<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<script type="text/javascript">
var click = function () {
alert(Ext.net.StringUtils.format("Panel is defined = {0}", App._pnl != null))
alert(Ext.net.StringUtils.format("Window is defined = {0}", App._wdn != null))
}
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Button Text="Click Me" runat="server">
<Listeners>
<Click Handler="click()" />
</Listeners>
</ext:Button>
<ext:Panel Title="Ext.Net" runat="server">
<Bin>
<ext:Panel ID="_pnl" Title="Panel" runat="server" />
<ext:Window ID="_wdn" Title="Window" Html="Content" runat="server" />
</Bin>
</ext:Panel>
</body>
</html>

RaphaelSaldanha
Dec 30, 2014, 9:20 PM
For now, i can suggest you to use HtmlBin, as shown below:


<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<script type="text/javascript">
var click = function () {
alert(Ext.net.StringUtils.format("Panel is defined = {0}", App._pnl != null))
alert(Ext.net.StringUtils.format("Window is defined = {0}", App._wdn != null))

if (App._wdn != null) {
App._wdn.show();
}
}
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Button Text="Click Me" runat="server">
<Listeners>
<Click Handler="click()" />
</Listeners>
</ext:Button>
<ext:Panel ID="_root" Title="Ext.Net" runat="server">
<HtmlBin>
<ext:Window ID="_wdn" Title="Window" Html="Content" Hidden="true" runat="server" />
</HtmlBin>
<Bin>
<ext:Panel ID="_pnl" Title="Panel" runat="server" />
</Bin>
</ext:Panel>
</body>
</html>

RaphaelSaldanha
Dec 30, 2014, 10:35 PM
The window is lazy, so during Window's ToScript, it retuns window as config instead window as control


public string ToScript(System.Web.UI.Control owner)
{
string cfg = new ClientConfig().Serialize(this, true);

if (this.IsLazy || this.ForceLazy || this.TemplateWidget || this.Factory != null)
{
return cfg;
}

return "new {0}({1}){2};".FormatWith(this.ClassName, cfg, this.Hidden ? "" : ".show()");
}

RaphaelSaldanha
Dec 30, 2014, 10:51 PM
Daniil, i would like to suggest the following approaches to overcome the issue:

#1 (preferred)


public string ToScript(System.Web.UI.Control owner)
{
string cfg = new ClientConfig().Serialize(this, true);

if (this.IsLazy || this.ForceLazy || this.TemplateWidget || this.Factory != null)
{
return string.Format("Ext.create(\"{0}\",{1})", this.ClassName, cfg);
}

return "new {0}({1}){2};".FormatWith(this.ClassName, cfg, this.Hidden ? "" : ".show()");
}


#2


public string ToScript(System.Web.UI.Control owner)
{
string cfg = new ClientConfig().Serialize(this, true);

if (this.IsLazy || this.ForceLazy || this.TemplateWidget || this.Factory != null)
{
return "new {0}({1})".FormatWith(this.ClassName, cfg);
}

return "new {0}({1}){2};".FormatWith(this.ClassName, cfg, this.Hidden ? "" : ".show()");
}



Oleg, let's wait for an answer from Daniil.

RaphaelSaldanha
Dec 30, 2014, 11:33 PM
Oleg, it's possible to overcome the issue by doing the following:

Solutuion #1: Localized; Render window after the panel rendering.


<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<script type="text/javascript">
var click = function () {
if (App._wdn != null) {
App._wdn.show();
}
}

var afterRender = function (panel) {
for (var index = 0; index < panel.bin.length; index++) {
var child = panel.bin[index];
if (child.xtype == "window") {
Ext.create("Ext.window.Window", child);
}
}
}
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Button Text="Click Me" RegisterAllResources="true" runat="server">
<Listeners>
<Click Handler="click()" />
</Listeners>
</ext:Button>
<ext:Panel ID="_root" Title="Ext.Net" runat="server">
<Bin>
<ext:Panel ID="_pnl" Title="Panel" runat="server" />
<ext:Window ID="_wdn" Title="Window" Html="Content" runat="server" />
</Bin>
<Listeners>
<AfterRender Fn="afterRender" />
</Listeners>
</ext:Panel>
</body>
</html>


Solutuion #2: Global; Render any window that is present within a Control's bin.


<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<script type="text/javascript">
var click = function () {
if (App._wdn != null) {
App._wdn.show();
}
}

Ext.override(Ext.ComponentManager, {
register: function (item) {
this.callParent(arguments);
if (item.bin != null) {
for (var index = 0; index < item.bin.length; index++) {
var child = item.bin[index];
if (child.xtype == "window") {
Ext.create("Ext.window.Window", child);
}
}
}
}
});
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Button Text="Click Me" runat="server">
<Listeners>
<Click Handler="click()" />
</Listeners>
</ext:Button>
<ext:Panel ID="_root" Title="Ext.Net" runat="server">
<Bin>
<ext:Panel ID="_pnl" Title="Panel" runat="server" />
<ext:Window ID="_wdn" Title="Window" Html="Content" runat="server" />
</Bin>
</ext:Panel>
</body>
</html>


Note: if Daniil incorporate one of the solutions provided on post #5, or provide a new one, you must remove the workaround provided above. So, check any update on this thread.

omazlov
Dec 31, 2014, 1:02 PM
Thank You Raphael for all you feedback!

Let's wait what Daniil will suggest (may be v.3.1 will not have the issue)

For now I will use one of your solutions ..

Daniil
Dec 31, 2014, 3:47 PM
Hello everybody,

Thank you for the report and workarounds!

I will be testing and investigating it soon after finishing with incorporating ExtJS 5.1.0 to Ext.NET.

RaphaelSaldanha
Jan 02, 2015, 10:51 PM
Thank you Daniil. Please keep us posted.

RaphaelSaldanha
Jan 14, 2015, 11:55 AM
I confirm that this issue is still reproducible on version 3.1.0.

Daniil
Jan 21, 2015, 8:50 AM
Finally, thank you for the report and all the investigation so far. Created an Issue:
https://github.com/extnet/Ext.NET/issues/645

Fixed in the revision #6263 (trunk). It goes to v3.1.0 beta.

I am closing the thread, but please feel free to update with any new relevant information.

RCN
Jan 21, 2015, 11:43 AM
I confirm that this issue has been fixed in the SVN trunk. It will go to v3.1.0 beta release.

Omazlov, now you can remove any workaround that you may have applied.