column header translations

column header translations

vismarkvismark Posts: 79Questions: 5Answers: 0

I'm searching in the manual a way to handle column header translations, but it seems that this function does not exist? Is there a way to build a dynamic column heading system? I mean something like this:

"columnDefs": [
    { "titleFb": "Fallback title", "title": "Translated title", "targets": 0 }
]

Moreover, is there a native way to let the user customize the column heading?

Replies

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @vismark ,

    You can use columns.title to change it at initialisation. Afterwards, you could just change the HTML if need be, like $(table.column(1).header()).text('fred');,

    Cheers,

    Colin

  • vismarkvismark Posts: 79Questions: 5Answers: 0

    Hi @colin

    the way you suggested is to manually pre-elaborate the "columnDefs" (or the "columns") content on the server side, so there's no way to have an automatic and dynamic fallback title in case of missing translations?

    I try to explain better my needs: in some scripts i reference the column title to obtain the relative index and assign some dynamic behaviour (like for example a background color). So changing the column title with the translated one would break those scripts. I would then need a way to assign an internal title (which for example might be the SQL query column name that doesn't change between localizations) and a displayed column title which might be everything else.

    What might be the best way to achieve this?

This discussion has been closed.