2016-05-17 24 views
0

我正在試圖獲取工具提示或帶2000圖像的表格中的單元格的標題。嘗試使用各種東西,但無法獲得任何解決方案。請幫忙。我對列代碼,jqgrid - 單元格的工具提示或標題不能顯示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; 
     } 
    } 
}, 

二碼試驗,

{ 
    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; 
     } 
    } 
}, 

上面的代碼時,有2000個字符沒有顯示任何提示。

也試過,

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

這是加載提示很慢。 請幫忙。

回答

0

1)我猜想使用title 2000 chars並不是個好主意。瀏覽器可能會截斷它(如Firefox),或者它會運行緩慢。

你可以試試這個代碼:

<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; 

現場演示: https://jsfiddle.net/hbofay8g/

2)更好的主意是使用懸停彈出。這裏 http://creativeindividual.co.uk/2011/02/create-a-pop-up-div-in-jquery/

描述的事情是在這種情況下,你有過的風格更多的控制:顏色,滾動,大小等

+0

謝謝你的答覆。我試過這個,但在我的jqgrid表中這個選項沒有工作:( – maddy

相關問題