Removing whitespace in table headers
Removing whitespace in table headers
wdupree
Posts: 5Questions: 0Answers: 0
I found that if I formatted the HTML so that the headers were like this:
[code]
Something
[/code]
instead of like this:
[code]
Something
[/code]
Then Datatables picked up all the carriage returns and whitespace - but didn't in the values. I noticed that back in 1.7 Datatables was changed to use $.trim to remove the whitespace of value cells - but this wasn't done for the header cells. If you change line 2342 (using version 1.8.2) from:
[code]
"sTitle": nTh ? nTh.innerHTML : '',
[/code]
to
[code]
"sTitle": nTh ? $.trim(nTh.innerHTML) : '',
[/code]
It trims all the header text so that it doesn't show up in PDFs, CSVs and Excel exports. Hope that helps others and can be added to future versions. Thanks for all the great work!
[code]
Something
[/code]
instead of like this:
[code]
Something
[/code]
Then Datatables picked up all the carriage returns and whitespace - but didn't in the values. I noticed that back in 1.7 Datatables was changed to use $.trim to remove the whitespace of value cells - but this wasn't done for the header cells. If you change line 2342 (using version 1.8.2) from:
[code]
"sTitle": nTh ? nTh.innerHTML : '',
[/code]
to
[code]
"sTitle": nTh ? $.trim(nTh.innerHTML) : '',
[/code]
It trims all the header text so that it doesn't show up in PDFs, CSVs and Excel exports. Hope that helps others and can be added to future versions. Thanks for all the great work!
This discussion has been closed.
Replies
Allan
Just to give you a heads up - I tried the 1.8.3.dev file that's currently on the site and it still does this for me in the header and footer. Plus, I found that if I added the following at line 2817:
[code]
anCells[i].innerHTML = $.trim(anCells[i].innerHTML);
[/code]
If got rid of the extra spaces in the footer cells. Hope that helps.