javascript - ExtJs 3.4 : Set tool tip for combo box

标签 javascript extjs combobox tooltip

我有一个 ExtJs 组合框,如下所示。我正在使用 ExtJS 3.4。我需要为此组合框设置悬停文本。即,当用户将鼠标悬停在此组合框上时,应出现消息文本。

new Ext.form.ComboBox({
        store : driverStore,
        displayField : 'dName',
        valueField : 'dName',
        fieldLabel : 'Driver Name',
        id : 'drivercombo',
        allowBlank : false,
        typeAhead : true,
        forceSelection : true,
        mode : 'local',
        triggerAction : 'all',
        selectOnFocus : true,
        editable : false,
        hidden : false,
        disabled : true,
        minChars : 1,
        hideLabel : true,
        style : 'marginleft:10px',
        //width : 147,
        emptyText : 'Driver Name',
        flex : 1
    });

我知道有一种方法可以为下拉菜单的组合框项目设置此工具提示消息。但我不想要它。我想要我的组合框的工具提示。

我该怎么做?

最佳答案

您可以在 combobox render 事件的监听器中创建 Ext.ToolTip ,并将其作为您可以定义的 tooltip 目标组合框元素。

var combo = new Ext.form.ComboBox({
    mode: 'local',
    renderTo: Ext.getBody(),
    store: new Ext.data.ArrayStore({
        id: 0,
        fields: [
            'myId',
            'displayText'
        ],
        data: [[1, 'item1'], [2, 'item2']]
    }),
    listeners: {
        render: function(c) {
          new Ext.ToolTip({
            target: c.getEl(),
            html: 'Tooltip content'
          });
        }
    },    
    valueField: 'myId',
    displayField: 'displayText'
});  

摆弄示例: https://fiddle.sencha.com/#fiddle/2q6

关于javascript - ExtJs 3.4 : Set tool tip for combo box,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21228172/

相关文章:

c++ - 凭据提供程序 'SetComboBoxSelectedValue' 未使用附加字段调用

javascript - HTML Dom 操作 : IE7 issue

extjs - 如何使用 Ext.example 中的文件

javascript - 即使我更改了 src 属性,视频仍然通过 https 加载?

iphone - 在 Xcode/Iphone 中测量 FPS/性能

layout - 如何获取用于容器的 ExtJS 布局

c# - 更简单地将许多枚举值添加到组合框

java - JavaFX ComboBox 元素上的文本颜色仅在第一次选择后更改

javascript - 变量在 angular.forEach 中不可访问

javascript - 带 setTimeout 的递归方法