-
29 Sep 2009 4:43 AM #1
[FIXED-279][3.0.x] Ext.Action and Ext.Toolbar.TextItem
[FIXED-279][3.0.x] Ext.Action and Ext.Toolbar.TextItem
Ext.Component is designed to be able to accept Ext.Action object as argument for constructor. But Ext.Toolbar.TextItem is not able to do it proprely.
Example:
Fix (red to remove, green to add):Code:// Some automatically updatable action that displays time var time = new Ext.Action({ text:(new Date()).format('d.m.Y H:i') }); var T = Ext.Toolbar; var toolbar = new T([ // Our action has no handler, so we prefer lightweight text item instead of button new T.TextItem(time) ]); // Toolbar is rendered empty
Code:var T = Ext.Toolbar; T.TextItem = Ext.extend(T.Item, { constructor: function(config){ if (Ext.isString(config)) { config = { text : config }; } if (Ext.isString(config)) { config = { autoEl: {cls: 'xtb-text', html: config }}; } else { config.autoEl = {cls: 'xtb-text', html: config.text || ''}; } T.TextItem.superclass.constructor.call(this, config); }, onRender : function(ct, position) { this.autoEl = {cls : 'xtb-text', html : this.initialConfig.text || ''}; T.TextItem.superclass.onRender.call(this, ct, position); }, … });
-
29 Sep 2009 5:04 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
Almost. IMHO it should be:
(removed reference to initialConfig and shortened the code a bit)Code:var T = Ext.Toolbar; T.TextItem = Ext.extend(T.Item, { constructor: function(config){ T.TextItem.superclass.constructor.call(this, Ext.isString(config) ? {text: config} : config); }, onRender : function(ct, position) { this.autoEl = {cls: 'xtb-text', html: this.text || ''}; T.TextItem.superclass.onRender.call(this, ct, position); }, … });
-
30 Sep 2009 3:06 PM #3
While not fixed in ExtJS code, you can use the following patch (just put somewhere after ExtJS code):
Code:Ext.override(Ext.Toolbar.TextItem, { onRender : function(ct, position) { this.autoEl = this.baseAction ? {cls: 'xtb-text', html: this.text || ''} : this.autoEl; Ext.Toolbar.TextItem.superclass.onRender.call(this, ct, position); } });
-
1 Oct 2009 8:09 AM #4
Fix applied to svn in rev #5444 for patch release 3.0.3.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote