最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to add tooltip to text form field in extjs6 - Stack Overflow

programmeradmin0浏览0评论

I have function for creating/rendering input fields but i don't know how to add tool tip on it in EXTjs6

this is my function:

createInputField: function(value, fieldsMarginBottom, readonly) {
        var fieldStyle = this.getFieldStyle(readonly);
        var nameField = Ext.create('Ext.form.field.Text', {
            name: 'name',
            readOnly: true,
            hideLabel: true,
            value: value,
            width: this.fieldWidth,
            style: {
                marginBottom: fieldsMarginBottom + 'px'
            },
            //My try which is not working
            tooltip: {
                trackMouse: true,
                width: 140,
                renderer: function(tip, item){
                    tip.setTitle('name');
                    tip.update('Count: ');
                }
            },
            fieldStyle: fieldStyle
        });
        return nameField;
    }

I hope you guys can help me. If you need any additional informations, please let me know and I'll provide. Thank you

I have function for creating/rendering input fields but i don't know how to add tool tip on it in EXTjs6

this is my function:

createInputField: function(value, fieldsMarginBottom, readonly) {
        var fieldStyle = this.getFieldStyle(readonly);
        var nameField = Ext.create('Ext.form.field.Text', {
            name: 'name',
            readOnly: true,
            hideLabel: true,
            value: value,
            width: this.fieldWidth,
            style: {
                marginBottom: fieldsMarginBottom + 'px'
            },
            //My try which is not working
            tooltip: {
                trackMouse: true,
                width: 140,
                renderer: function(tip, item){
                    tip.setTitle('name');
                    tip.update('Count: ');
                }
            },
            fieldStyle: fieldStyle
        });
        return nameField;
    }

I hope you guys can help me. If you need any additional informations, please let me know and I'll provide. Thank you

Share Improve this question edited Jul 5, 2018 at 12:24 Barak 237 bronze badges asked Jul 11, 2016 at 6:17 Valor_Valor_ 3,6019 gold badges64 silver badges116 bronze badges 2
  • Where in the docs did you find the tooltip configuration? – Alexander Commented Jul 11, 2016 at 6:45
  • I haven't. I was googling around how to, but nothing seems to work. Do you have any idea how to implement this? – Valor_ Commented Jul 11, 2016 at 6:47
Add a ment  | 

2 Answers 2

Reset to default 5

As can be seen in the textfield docs, fields do not have a way to add a tooltip to their configuration, so you would have to create the tooltip manually.

If you look at the docs for Ext.tip.ToolTip how to do that, you may find a small example, where you just have to change the target as per the target configuration description:

var tip = Ext.create('Ext.tip.ToolTip', {
    target: nameField.getEl(),
    html: 'Press this button to clear the form'
});

Above answer is correct. Here is example of generic function which you write once and use wherever you required in project by using using attributes.

addToolTip : function (id, msg) {
    new Ext.ToolTip({
            target : id,
            dismissDelay : 0,
            anchor : 'right',
            html : msg
        });
};
发布评论

评论列表(0)

  1. 暂无评论