[CLOSED] [#675] ComponentLoader loading component with plugins
Hi,
I am struggling to use ComponentLoader when the component has plugins.
Here is a sample text page:
HTML Code:
<%@ Page Language="C#" %>
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<title>Component loader view MVC Controller</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Panel runat="server" Width="400" Height="400" Layout="fit">
<Loader Mode="Component" Url="~/Loader/PanelContent">
<AjaxOptions Method="POST" />
<LoadMask ShowMask="true" />
</Loader>
</ext:Panel>
</body>
</html>
Here is an example of an MVC Controller that works
Code:
public class LoaderController : Controller
{
public ActionResult PanelContent()
{
return Json(ComponentLoader.ToConfig(new Panel
{
Title = "Panel with random plugin",
Html = "Some content"
}));
}
}
The above works fine (for me, if I added some icon to the Icon property it doesn't show up, but I can live with that - it might be related to a separate thread we are tracking about modules/handlers etc, which I still need to look into). The main thing for me is that the AJAX response is like this (in its raw form according to the browser console)
"[{html:\"Some content\",xtype:\"panel\",title:\"Panel with random plugin\"}]"
Now, if I try to add any random plugin, I get a problem:
Code:
public class LoaderController : Controller
{
public ActionResult PanelContent()
{
return Json(ComponentLoader.ToConfig(new Panel
{
Title = "Panel with random plugin",
Html = "Some content",
Plugins =
{
new ClearButton()
}
}));
}
}
With the above, all is the same, except the addition of a plugins configuration. Now, the response returns with HTTP 200 (ok), but nothing is rendered on the screen.
Notice in this case the JSON response is quite different with various escape characters etc (unencoded/raw)
(I have replaced the value of the webresource.axd querystring with [snip] just for clarity
"{\u0027x.res\u0027:{res:[{url:\"/WebResource.axd?d=[snip]\u0026amp;t=635574427442910000\"}]},config:\"[{html:\\\"Some content\\\",plugins:[{ptype:\\\"clearbutton\\\"}],xtype:\\\"panel\\\",title:\\\"Panel with random plugin\\\"}]\"}"
The first character (\u0027x) is unicode for apostrophe. And then further along is a number of not just single escaped quotes, \" but with double slashes, \\" etc.
I see some overloads for the ToConfig method but I am not clear how to use the overloads that take a component prerenderer as I could not see any uses of those in the Ext.NET code or examples (unless I missed it). And I am not clear if I am meant to use those overrides or not. I would expect I just call ToConfig as I am doing right now.
The only alternative I can see to this is to use a DirectMethod (which I normally do instead) but it would be nice to get ComponentLoader to work.
Any suggestions to what I am missing here?