2

下面是组合代码:

Ext.define('Grade', {
    extend: 'Ext.data.Model',
    fields: [
        { name: 'id', type: 'int' },
        { name: 'name', type: 'string' }
    ]
});
 
Ext.define('GradeCombo', {
    extend: 'Ext.form.field.ComboBox',
    alias: 'widget.gradecombo',
    queryMode: 'local',
    valueField: 'id',
    displayField: 'name',
    store: {
        model: 'Grade',
        data: [
            { id: 1, name: 'A' },
            { id: 2, name: 'B' },
            { id: 3, name: 'C' }
        ]
    }
});

这是组合的布局代码:

Ext.onReady(function(){

Ext.widget('panel', {
    renderTo: 'pan1',
    title: 'Basic Panel',
    width:300,
    height:100,
    defaults: {
        bodyPadding: 10,
        border: false,
        xtype: 'panel',
        layout: 'anchor'
    },
    layout: 'hbox',
    items: [{
                  fieldLabel: 'Grade',
                  xtype: 'gradecombo',
                  width: 234
           }]            
});  
});

当用户将鼠标悬停在组合项目的下拉菜单上时,我想显示每个等级的描述的工具提示消息。这是描述商店:

var store = ['Marks between 70 and 80', 'Marks between 60 and 70', 'Marks between 50 and 60'];

请让我知道如何实现这一目标。

问候,

4

1 回答 1

4

我不相信默认情况下可以设置工具提示属性,但是您可以通过覆盖组合框 listConfig 属性的 getInnerTpl 方法来完全自定义下拉列表中显示的内容,如下所示:

     listConfig: {
            loadingText: 'Searching...',
            emptyText: 'No matching posts found.',
            // Custom rendering template for each item
            getInnerTpl: function() {
                return '<a class="search-item" href="http://www.sencha.com/forum/showthread.php?t={topicId}&p={id}">' +
                    '<h3><span>{[Ext.Date.format(values.lastPost, "M j, Y")]}<br />by {author}</span>{title}</h3>' +
                    '{excerpt}' +
                '</a>';
            }
        }

完整代码示例: http ://docs.sencha.com/ext-js/4-1/extjs-build/examples/form/forum-search.js

And most importantly the tip itself. Add the following html attribute to any element you are creating in your template : data-qtip="This is a quick tip from markup!" You can further control your tooltip by following these guidelines: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.tip.QuickTipManager

于 2012-10-02T23:01:34.260 回答