javascript Extjs 4 网格鼠标悬停显示完整的单元格值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12207018/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 15:35:28  来源:igfitidea点击:

Extjs 4 grid mouseover show full cell value

javascriptgridextjs4javascript-framework

提问by alex9311

I've got a grid with a long string in one of the columns. I would like the full string to appear when the user mouses over any cell in this column.

我在其中一列中有一个带有长字符串的网格。当用户将鼠标悬停在此列中的任何单元格上时,我希望显示完整的字符串。

So far I have it working where a tooltip pops up for any cell in this column but they don't display the text. The tooltip always just says "Icon Tip".

到目前为止,我可以在此列中的任何单元格弹出工具提示的情况下工作,但它们不显示文本。工具提示总是只说“图标提示”。

How do I get the qtip to display the variable val instead of the string "Icon Tip"?

如何让 qtip 显示变量 val 而不是字符串“Icon Tip”?

Ext.define('AM.view.user.List' , {
    extend: 'Ext.grid.Panel',
    .......
    initComponent: function() {
        function renderTip(val, meta, rec, rowIndex, colIndex, store) {
            meta.tdAttr = 'data-qtip="Icon Tip"';
            return val;
        };
        this.columns = [
            {header: 'First Name', dataIndex: 'FirstName', width: 75},
            {header: 'Last Name', dataIndex: 'Last', width: 75},
            {header: 'Perm', dataIndex: 'Perm', width: 75},
            {header: 'Comment', dataIndex: 'Comments', width: 150, renderer: renderTip}
        ];
        this.callParent(arguments);
    }
});

回答by alex9311

Figured it out on the sencha forums, the correct code would be:

在sencha论坛上弄清楚,正确的代码是:

function renderTip(value, metaData, record, rowIdx, colIdx, store) {
    metaData.tdAttr = 'data-qtip="' + value + '"';
    return value;
};

I guess there was some string/variable concatenation I needed to use

我想我需要使用一些字符串/变量连接

http://www.sencha.com/forum/showthread.php?179016-Grid-cell-tooltip

http://www.sencha.com/forum/showthread.php?179016-Grid-cell-tooltip

回答by Evan Trimboli

You already have the value, it gets passed as the first argument to the renderer. If you need more information, you also have the record.

您已经拥有该值,它将作为第一个参数传递给渲染器。如果您需要更多信息,您还有记录。