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

10

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

到目前为止,我已经让工具提示在该列中的任何单元格上弹出,但它们不显示文本。工具提示始终只显示“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);
    }
});
2个回答

13

1

你已经有了数值,它将作为第一个参数传递给渲染器。如果需要更多信息,你也可以使用记录。


谢谢您的回答。值和记录之间有什么区别?我以为用 meta.tdAttr = 'data-qtip="Icon Tip"';替换meta.tdAttr = 'data-qtip=val';会在工具提示中显示单元格的值,但现在所有单元格都只显示“val”。 - alex9311
1
值是绑定在数据索引中的值,记录是具有所有值的整个模型。不确定您对编程的熟悉程度,但val是一个变量。因此,在= val和=“val”之间存在差异。 - Evan Trimboli
是的,我发现 meta.tdAttr = 'data-qtip="Icon Tip"' 会在工具提示中显示字符串 "Icon Tip",它确实做到了。我以为 meta.tdAttr = 'data-qtip=val' 会在工具提示中显示变量 val 中包含的字符串,但它只显示 "val"。感谢您的回复! - alex9311
从这个线程中找到了解决方案:http://www.sencha.com/forum/showthread.php?179016-Grid-cell-tooltip - alex9311

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接