Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext User anotherpit's Avatar
    Join Date
    Nov 2007
    Posts
    21
    Vote Rating
    0
    anotherpit is on a distinguished road

      0  

    Default [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:
    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
    Fix (red to remove, green to add):
    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);
        },
        …
    });

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    97
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Almost. IMHO it should be:
    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);
        },
        …
    });
    (removed reference to initialConfig and shortened the code a bit)

  3. #3
    Ext User anotherpit's Avatar
    Join Date
    Nov 2007
    Posts
    21
    Vote Rating
    0
    anotherpit is on a distinguished road

      0  

    Default


    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);
        }
    });

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,170
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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!

Thread Participants: 2