如何向extjs列标题添加自定义css工具提示?

[英]How add custom css tooltip to extjs column header?


I am new to extjs . I am trying to add tooltip preferably css based to the column headers . How can I go about adding custom tooltip to the extjs column header using css? the extjs default way doesnt seem to work.

我是extjs的新手。我正在尝试添加工具提示,最好是基于列标题的css。如何使用css向extjs列标题添加自定义工具提示?extjs默认的方式似乎不起作用。

I tried using the custom css tooltip for the header and it didnt work .. Is it at all possible in extjs to custom tooltip on the header?

我尝试使用自定义的css工具提示来处理标题,但是没有成功。在extjs中是否可以在标题上使用自定义工具提示?

Thanks

谢谢

var listView = Ext.create('Ext.grid.Panel', {
      store: mystore,
      multiSelect: true,
      splitHandleWidth: 10,
      columnLines: true,
       viewConfig: {
        emptyText: 'No images to display'
      },

      renderTo: containerEl,

      columns: [{
        text: '<a href="#" class="ttip" title="'+m.i18n.getString('notif.class')+'">'+e.i18n.getString('notif.class')+'<span class="classic">'+e.i18n.getString('notif.class')+'</span></a>',
        flex: 10,
        dataIndex: 'CName',
        tooltip: 'C Name Some name test',

        renderer: function (value, metaData, record) {
                    return Ext.String.format('<a href="#" class="tooltip2" >{0}<span>{0}</span></a>', value);
                }
      }, {
        text: getString('notif.instance'),
        flex: 30,
        dataIndex: 'IDisplayName',
        renderer: function (value, metaData, record) {


   return Ext.String.format('<a href="#" class="tooltip2" >{0}<span>{0}</span></a>', value);
                }
      }]
    });

CSS

CSS

     .ttip {
            border-bottom: 0px dotted #000000; color: #000000; outline: none;
    /*        cursor: help; */
             text-decoration: none;
            position: relative;
        }
        .ttip span {
            margin-left: -999em;
            position: absolute;text-decoration: none;
        }
        .ttip:hover,.ttip:active, .ttip:link,.ttip:visited{text-decoration: none; color:#000;}
        .ttip:hover span {
            border-radius: 5px 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; 
            box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
            font-family: Calibri, Tahoma, Geneva, sans-serif;
            position: absolute; left: 1em; top: 2em; z-index: 9999999;
            margin-left: 0; width: 250px; 
        }
        .ttip:hover img {
            border: 0; margin: -10px 0 0 -55px;
            float: left; position: absolute;
        }
        .ttip:hover em {
            font-family: Candara, Tahoma, Geneva, sans-serif; font-size: 1.2em; font-weight: bold;
            display: block; padding: 0.2em 0 0.6em 0;
        }
        .classic { padding: 0.8em 1em; }
        .custom { padding: 0.5em 0.8em 0.8em 2em; }
        * html a:hover { background: transparent; }
        .classic {background: #FFFFAA; border: 1px solid #FFAD33; }
        .critical { background: #FFCCAA; border: 1px solid #FF3334;    }
        .help { background: #9FDAEE; border: 1px solid #2BB0D7;    }
        .info { background: #9FDAEE; border: 1px solid #2BB0D7;    }
        .warning { background: #FFFFAA; border: 1px solid #FFAD33; }

​

2 个解决方案

#1


3  

So, I noticed you provided code for your store, but you are asking a question about the grid, which is a different component. Make sure you understand the relationship between the grid and the store. You should also use a Model definition instead of configuring fields on the store - which is the old way of doing things.

因此,我注意到您为您的商店提供了代码,但是您正在询问关于网格的问题,这是一个不同的组件。确保您理解了网格和存储之间的关系。您还应该使用模型定义,而不是在商店中配置字段——这是旧的方法。

Having said that, I did come up with an interesting solution to your question: how to add a tooltip to the column header.

说到这里,我确实找到了一个有趣的解决方案:如何向列标题添加工具提示。

The column definition takes in a 'text' property that gets converted to the column header. The docs state that HTML tags are allowed, which means you can set a tooltip this way:

列定义接受一个“text”属性,该属性被转换为列标头。文档声明允许HTML标记,这意味着您可以这样设置工具提示:

text: '<span data-qtip="hello">First Name</span>'

where data-qtip provides the text for the tooltip. Note that tooltips must be enabled via: Ext.QuickTips.init(); in your app.

在这里,data-qtip为工具提示提供文本。注意,工具提示必须通过:Ext.QuickTips.init()启用;在你的应用程序。

To try other things use the docs Live Preview feature to quickly test out different configs and see them in action. http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.column.Column

为了尝试其他的事情,使用docs Live预览功能,快速测试不同的配置,并在操作中看到它们。http://docs.sencha.com/ext-js/4-0/ # ! / api / Ext.grid.column.Column

UPDATE: a tooltip property is now(since 4.1x) available on column config. Use that.

更新:工具提示属性现在(因为4.1x)在列配置上可用。使用它。

#2


0  

In the definition of your columns you only need set the tooltip parameter, like this:

在您的列的定义中,您只需要设置工具提示参数,如下所示:

var cm =  new Ext.grid.ColumnModel([
  {
    xtype: 'column',
    header: '<img src="../images/lupa.png">',
    align: 'center',
    dataIndex: 'consultar',
    width: 50,
    sortable: true,
    menuDisabled: true,
    tooltip: 'Permisos para consultar, si lo desactiva el usuario no verá el modulo'
  }
 ]);

I hope this help you

我希望这对你有帮助。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/02/23/8eb22cf6ece0901977455b063fb02c67.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com