Open GoogleCodeExporter opened 8 years ago
Here's a patch that can fix this:
Index: js/flexigrid.js
===================================================================
--- js/flexigrid.js (revision 14)
+++ js/flexigrid.js (working copy)
@@ -44,6 +44,7 @@
autoload: true,
blockOpacity: 0.5,
preProcess: false,
+ addTitleToCell: false, // add a title attr to cells with truncated contents
onDragCol: false,
onToggleCol: false,
onChangeSort: false,
@@ -212,7 +213,9 @@
$('th:visible div:eq(' + n + ')', this.hDiv).css('width', nw);
$('tr', this.bDiv).each(
function () {
- $('td:visible div:eq(' + n + ')', this).css('width', nw);
+ var $tdDiv = $('td:visible div:eq(' + n + ')', this);
+ $tdDiv.css('width', nw);
+ g.addTitleToCell($tdDiv);
}
);
this.hDiv.scrollLeft = this.bDiv.scrollLeft;
@@ -627,6 +630,7 @@
if (pth.process) pth.process(tdDiv, pid);
}
$(this).empty().append(tdDiv).removeAttr('width'); //wrap content
+ g.addTitleToCell(tdDiv);
});
},
getCellDim: function (obj) {// get cell prop for editable event
@@ -682,6 +686,28 @@
}
});
},
+ //Add title attribute to div if cell contents is truncated
+ addTitleToCell: function(tdDiv) {
+ if(p.addTitleToCell) {
+ var $span = $('<span />').css('display', 'none'),
+ $div = (tdDiv instanceof jQuery) ? tdDiv : $(tdDiv),
+ div_w = $div.outerWidth(),
+ span_w = 0;
+
+ $('body').children(':first').before($span);
+ $span.html($div.html());
+ $span.css('font-size', '' + $div.css('font-size'));
+ $span.css('padding-left', '' + $div.css('padding-left'));
+ span_w = $span.innerWidth();
+ $span.remove();
+
+ if(span_w > div_w) {
+ $div.attr('title', $div.text());
+ } else {
+ $div.removeAttr('title');
+ }
+ }
+ },
pager: 0
};
if (p.colModel) { //create model if any
Original comment by scott.ke...@gmail.com
on 23 Mar 2012 at 11:55
Original issue reported on code.google.com by
scott.ke...@gmail.com
on 23 Mar 2012 at 4:49