Setting a max column width by checking the length of string.
Setting a max column width by checking the length of string.
frequency9
Posts: 1Questions: 0Answers: 0
I am implementing a feature just like in excel. When i double click on a TH the column needs to set the width by checking the max string length in that column. I got it working only if there are no spaces in the string. but i need to get the max length of whole string even with spaces. how can i get that?
here is my code :
[code]
$('#example thead th').dblclick(function() {
var width = oTable.oApi._fnGetMaxLenString(oTable.fnSettings(), $(this).index());
oTable.fnSettings().aoColumns[$(this).index()].sWidth = width+"px";
oTable.fnDraw();
});
[/code]
Here is the debug code :udecen
here is my code :
[code]
$('#example thead th').dblclick(function() {
var width = oTable.oApi._fnGetMaxLenString(oTable.fnSettings(), $(this).index());
oTable.fnSettings().aoColumns[$(this).index()].sWidth = width+"px";
oTable.fnDraw();
});
[/code]
Here is the debug code :udecen
This discussion has been closed.