cansadadeserfeliz
cansadadeserfeliz

Reputation: 3133

ExtJS 4: Is there any way to attach a QuickTip to a form field?

I'm trying to add a QuickTip to a form field, but can't find a way to make my code work. Firstly, I tried to use a qtip attribute

    {
        fieldLabel: 'Last Name',
        qtip:'This tip is not showing at all',
        name: 'last'
    }

and then using Ext.tip.ToolTip class:

Ext.create('Ext.tip.ToolTip', {
    target: 'rating_field',
    anchor: 'right',
    trackMouse: true,
    html: 'This tip is not showing at all'
});

Ext.QuickTips.init();

Here is a jsfiddle with the source code: jsfiddle

Upvotes: 10

Views: 16749

Answers (6)

Steefler35
Steefler35

Reputation: 123

For any form field, you can use this:

{
    xtype: 'textfield', // or anything else
    autoEl: {
        'data-qtip': 'This is working tip!'
    }
}

Upvotes: 3

Nilay Mehta
Nilay Mehta

Reputation: 1907

If you are generating tooltip dynamically then you can use below snippet:

txtFieldName.el.set({ "data-qtip": Ext.String.htmlDecode("Some Text") });

Upvotes: 0

Arnaud Benhamdine
Arnaud Benhamdine

Reputation: 91

You can also use the built-in plugin datatip on a form panel. in form panel (see http://docs.sencha.com/extjs/6.5.1/classic/Ext.ux.DataTip.html) :

in form config :

plugins = [{ptype : 'datatip'}]

in field text config :

tooltip : "my tooltip text"

Upvotes: 0

Will S
Will S

Reputation: 755

Using vero4ka's answer I wrote a simple plugin which can be used with forms to enable quicktips on child fields.

Ext.define('Ext.form.QtipPlugin', {
    extend: 'Ext.AbstractPlugin',

    alias: 'plugin.qtipfields',

    init: function (cmp) {
        this.setCmp(cmp);

        cmp.on('beforerender', function () {

            var fields = cmp.query('field[qtip]');

            for (var i = 0; i < fields.length; i++) {

                fields[i].on('render', this.register, this);

            }

        }, this);
    },

    register: function (field) {
        var obj = {
            target: field.id
        };

        if (typeof field.qtip === 'string') {
            obj.text = field.qtip;
        } else if (typeof field.qtip === 'object') {
            // Allow qtip configuration objects.
            // i.e. qtip: { text: 'hi', ... }
            Ext.applyIf(obj, field.qtip);
        }

        Ext.tip.QuickTipManager.register(obj);
    }
});

Upvotes: 4

cansadadeserfeliz
cansadadeserfeliz

Reputation: 3133

I found the answer here: How should I add a tooltip to an ExtJS Component?

    {
        fieldLabel: 'Last Name',
        qtip: "This is a tip",
        name: 'last',
        listeners: {
            render: function(c) {
                Ext.QuickTips.register({
                    target: c.getEl(),
                    text: c.qtip
                });
            }
        }
    }

Upvotes: 8

Reimius
Reimius

Reputation: 5712

Yes, use the inputAttrTpl config and the data-qtip attribute:

{
    fieldLabel: 'Last Name',
    inputAttrTpl: " data-qtip='This is my quick tip!' ",
    name: 'last'
}

Upvotes: 24

Related Questions