aoColumnDefs sTitle -> TableTools CSV export

aoColumnDefs sTitle -> TableTools CSV export

robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
edited September 2012 in General
I'm using aoColumnDefs sTitle to conditionally change long header text to shorter text, e.g. "This is too long for a TH" changes to "This is too...".

The underlying HTML table TH element has the title attribute set to "This is too long for a TH" so that the tool tip will show the entire text.

But when I export to CSV using TableTools, the truncated sTitle is used.

How can I get TableTools to use the original text from the TH element, and not what is specified in sTitle?

Many, many thanks.

Robert

Replies

  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    Does anyone know if this use case is covered?
  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    Let me refine my use case, then maybe someone can tell me if it is doable. The text in the column headers can be quite long, e.g. 1234567890123456789012345678901234567890.

    It will not wrap. So i want to shorten it and provide the tool tip.

    Anyone at all?

    Thanks!
  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    Hi Allan.

    Can you offer me any advice on this?

    Thanks.

    Robert
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    This is the line in TableTools that defines what is used on the output: https://github.com/DataTables/TableTools/blob/9d93593c454394b0d40b0283b86c92e824c4f46c/media/js/TableTools.js#L1525

    So there is currently no way to override that in TableTools. You'd need to modify the TableTools source to read from an attribute:

    [code]
    dt.aoColumns[i].nTh.getAttribute('title');
    [/code]

    for example.

    Allan
  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    Thanks for the response. I wish there were a fnRender method for the TH elements like there is for the TD elements.

    I'll just load my custom Table tools js file for this one page.

    Thanks!

    Robert
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Feel free to fork and add it :-). Pull requests are always great fully received!

    Allan
  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    edited October 2012
    Will do

    Robert
This discussion has been closed.