jqgrid - 不显示2000 +字符的单元格的工具提示或标题

时间:2022-09-06 22:19:17

I am trying to get tooltip or title with 2000 characters for a cell in a table with image. Tried using various things but not able to get any solution. Please help. My code for the column,

我试图获得带有图像的表格中的单元格的2000个字符的工具提示或标题。尝试使用各种东西,但无法得到任何解决方案。请帮忙。我的专栏代码,

    {
    name: 'comments',
    index: 'comments',
    width: 80,
    align: 'center',
    resizable: true,
    sortable: false,
    editable: false,
    cellattr: function(rowId, val, rawObject) {
        return 'title="' + val + '"'
    },
    formatter: function(cellvalue, options, rowobject) {
        if (cellvalue.length <= 0) {
            return cellvalue;
        } else {
            var image = "<img src='/images/comment.png' />";
            return image;
        }
    }
},

Second code trial,

第二次代码试用,

{
    name: 'comments',
    index: 'comments',
    width: 80,
    align: 'center',
    resizable: true,
    sortable: false,
    editable: false,
    formatter: function(cellvalue, options, rowobject) {
        if (cellvalue.length <= 0) {
            return cellvalue;
        } else {
            var image = "<img src='/images/comment.png' title='Comments:\n" + cellvalue + "'/>";
            return image;
        }
    }
},

Above code did not display any tooltip when there are 2000 characters.

当有2000个字符时,上面的代码没有显示任何工具提示。

Also tried,

var image = '<figure><img src='/images/comment.png' title='Comments:\n"+cellvalue+"'/></figure>';

This is loading the tooltip very slow. Please help.

这样加载工具提示非常慢。请帮忙。

1 个解决方案

#1


0  

1) I guess it's not good idea to use title 2000 chars long. Browser may truncate it (like Firefox) or it will work slow.

1)我想使用标题2000字符长并不是一个好主意。浏览器可能会截断它(如Firefox),否则它会很慢。

You may try this code:

您可以尝试以下代码:

<figure><img src='/images/comment.png' id='img'/></figure>

var x = '1234567890';
var y = '';

for (var j=0;j<200;j++)
y+=x;

var i = document.getElementById('img');
i.title = y;

Live demo: https://jsfiddle.net/hbofay8g/

现场演示:https://jsfiddle.net/hbofay8g/

2) Much better idea is use hover popup. Something like described here http://creativeindividual.co.uk/2011/02/create-a-pop-up-div-in-jquery/

2)更好的想法是使用悬停弹出窗口。这里描述的东西http://creativeindividual.co.uk/2011/02/create-a-pop-up-div-in-jquery/

In this case you have more control over style: color, scrolls, size etc.

在这种情况下,您可以更好地控制样式:颜色,滚动,大小等。

#1


0  

1) I guess it's not good idea to use title 2000 chars long. Browser may truncate it (like Firefox) or it will work slow.

1)我想使用标题2000字符长并不是一个好主意。浏览器可能会截断它(如Firefox),否则它会很慢。

You may try this code:

您可以尝试以下代码:

<figure><img src='/images/comment.png' id='img'/></figure>

var x = '1234567890';
var y = '';

for (var j=0;j<200;j++)
y+=x;

var i = document.getElementById('img');
i.title = y;

Live demo: https://jsfiddle.net/hbofay8g/

现场演示:https://jsfiddle.net/hbofay8g/

2) Much better idea is use hover popup. Something like described here http://creativeindividual.co.uk/2011/02/create-a-pop-up-div-in-jquery/

2)更好的想法是使用悬停弹出窗口。这里描述的东西http://creativeindividual.co.uk/2011/02/create-a-pop-up-div-in-jquery/

In this case you have more control over style: color, scrolls, size etc.

在这种情况下,您可以更好地控制样式:颜色,滚动,大小等。