PDA

View Full Version : [OPEN] Override of container renderTpl results in ownerCt is null



hkelsey
30 Apr 2013, 6:35 AM
REQUIRED INFORMATION Ext version tested:

Ext 4.2.0.663

Browser versions tested against:

FF20(firebug 1.11.2 installed)
chrome 25

Description:

If you override the renderTpl an error is thrown, ownerCt is null and prevents proper
sizing of the container. This worked in 4.0.x and 4.1.x.

Steps to reproduce the problem:

The result that was expected:

No error thrown

The result that occurs instead:

ownerCt is null error

Test Case:
Ext.define( 'app.container',{
extend: 'Ext.container.Container',
renderTo : Ext.getBody(),
initComponent: function() {
var me = this;

Ext.apply(me, {
id: "login-container",
minHeight: 510,
renderTpl: new Ext.XTemplate('<div id="login-panel">',
'<div class="brand-image"></div>',
'<div class="login-image"></div>',
'<div class="title-form-container">',
'<h1>{title}</h1>',
'<div id="login-form-container"></div>',
'<span class="error" style="visibility: hidden;"></span>',
'</div>',
'<div class="copyright">',
'{copyright}',
'</div>',
'</div>'),
renderData: {
title:"application",
copyright: "copyright",
version: "version"
},
renderSelectors: {
formContainerEl: '#login-form-container',
errorEl: '#login-container .error'
}
});
me.callParent(arguments);
}
});

Ext.create('app.container', {renderTo: Ext.getBody()}); HELPFUL INFORMATION

See this URL for live test case: http:// Debugging already done:

none

Possible fix:

not provided

Additional CSS used:

only default ext-all.css
custom css (include details)

Operating System:

Ubuntu 12.10/13.04
Windows 7

slemmon
30 Apr 2013, 12:53 PM
Thanks for the report! I have opened a bug in our bug tracker.

evant
30 Apr 2013, 1:53 PM
There's a few problems with the test case:

1) There's only very rare circumstances where you should (or need to) change the renderTpl, the internal implementation of components rely on certain things being there.
2) You're extending Ext.container.Container, but not using any of the features of a container, just rendering markup.
3) Changing the renderTpl doesn't actually achieve anything, since you're rendering content, not structure, you can use the tpl property:



Ext.define( 'app.container',{
extend: 'Ext.Component',
id: "login-container",
initComponent: function() {
var me = this;

Ext.apply(me, {
minHeight: 510,
tpl: new Ext.XTemplate('<div id="login-panel">',
'<div class="brand-image"></div>',
'<div class="login-image"></div>',
'<div class="title-form-container">',
'<h1>{title}</h1>',
'<div id="login-form-container"></div>',
'<span class="error" style="visibility: hidden;"></span>',
'</div>',
'<div class="copyright">',
'{copyright}',
'</div>',
'</div>'),
data: {
title:"application",
copyright: "copyright",
version: "version"
},
renderSelectors: {
formContainerEl: '#login-form-container',
errorEl: '#login-container .error'
}
});
me.callParent(arguments);
}
});

Ext.onReady(function(){


var ct = Ext.create('app.container', {
renderTo: Ext.getBody()
});
console.log(ct.formContainerEl, ct.errorEl);

});

hkelsey
1 May 2013, 1:53 AM
Hi Evant
Thanks for the quick response, I've applied the changes you suggested.