Nov 19, 2012, 4:36 PM
[CLOSED] Manually loading controls
Some days ago i started a thread regarding the load of controls during view creation:
http://forums.ext.net/showthread.php...-View-creation
but after updating from SVN, my code stopped working. After analysing ComponentLoader implemetation, i noticed that it was due a new functionality of ComponentLoader, that registers controls' resources on ResourceManager.
To overcome the problem, i had to implement docReady function as shown bellow:
1 - View
App._hddContent.value when the View Creation line 7 is commented
3 - New Javascript code
Any ideas to overcome this issue?
http://forums.ext.net/showthread.php...-View-creation
but after updating from SVN, my code stopped working. After analysing ComponentLoader implemetation, i noticed that it was due a new functionality of ComponentLoader, that registers controls' resources on ResourceManager.
To overcome the problem, i had to implement docReady function as shown bellow:
1 - View
<script runat="server">
public void Page_Load(object sender, EventArgs e)
{
ResourceManager.RegisterControlResources<SelectBox>();
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Index</title>
<script type="text/javascript">
var docReady = function () {
var decoded = Ext.decode(App._hddContent.value);
if (decoded.config != null) {
decoded = Ext.decode(decoded.config);
}
App._pnlContainer.add(decoded);
App._hddContent.destroy();
}
</script>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server">
<Listeners>
<DocumentReady Handler="docReady();" />
</Listeners>
</ext:ResourceManager>
<ext:Panel ID="_pnlContainer" TitleCollapse="true" Border="false" runat="server" />
<ext:Hidden ID="_hddContent" Width="400" Text="<%# ViewBag.DynamicContent %>" AutoDataBind="true"
runat="server" />
</body>
</html>
2 - View Creationpublic ActionResult Index()
{
Panel pnlControls = new Panel();
pnlControls.Items.Add(new Button());
//pnlControls.Items.Add(new SelectBox());
ViewBag.DynamicContent = ComponentLoader.ToConfig(pnlControls);
return View();
}
App._hddContent.value when the View Creation line 7 is commented
[{
xtype: "panel",
items: [{
xtype: "button"
}]
}]
App._hddContent.value when the View Creation line 7 is uncommented{
'x.res': {
res: [{
url: "/ux/selectbox/selectbox-js/ext.axd?v=18148"
}]
},
config: "[{xtype:\"panel\",items:[{xtype:\"button\"},{xtype:\"selectbox\",queryMode:\"local\",triggerAction:\"all\",store:Ext.data.StoreManager.getArrayStore(2)}]}]"
}
But i would like to take the advantage of new ComponentLoader implementation, that registers controls' resources, so i copied ComponentLoader implementation and adapted to my scneario, as shown bellow:3 - New Javascript code
<script type="text/javascript">
var docReady = function () {
var decoded = processContent(App._hddContent.value);
App._pnlContainer.add(decoded);
App._hddContent.destroy();
}
var processContent = function (resp) {
if (Ext.isObject(resp)) {
cfg = resp;
}
else if (Ext.isString(resp)) {
cfg = Ext.decode(resp, true);
resp = cfg;
}
else {
cfg = null;
}
if (cfg && cfg['x.res']) {
if (cfg['x.res'].ns) {
Ext.ns.apply(Ext, cfg['x.res'].ns);
}
if (cfg.config) {
resp = Ext.decode(cfg.config, true);
}
if (cfg['x.res'].res) {
Ext.net.ResourceMgr.load(cfg['x.res'].res);
}
}
return resp;
}
</script>
But if i remove View lines 1 to 6 (shown bellow), an is exception is thrown during namespaceRewrites.<script runat="server">
public void Page_Load(object sender, EventArgs e)
{
ResourceManager.RegisterControlResources<SelectBox>();
}
</script>
I think my code dic not act properly on New Javascript code line 33, in other words, it was not able to register controls' resources.Any ideas to overcome this issue?
Last edited by Daniil; Nov 20, 2012 at 12:35 PM.
Reason: [CLOSED]