How to use "Ellipsis Renderer" for screen only, and not for export to excel

How to use "Ellipsis Renderer" for screen only, and not for export to excel

rdmrdm Posts: 187Questions: 52Answers: 4
edited October 2022 in DataTables 1.10

I found the ellipsis renderer for truncating long text. It works great, but the only downside is that it also truncates exported text. Is there a way to only truncate text on the screen, but not in export?

Here's what I'm using.

$(() => {
// This render function truncates anything more than 100 characters.
$.fn.dataTable.render.ellipsis = function () {
return function ( data, type, row ) {
return type === 'display' && data.length > 100 ?
data.substr( 0, 100 ) +'…' :

        // Only column 11 uses the render function.
            dom: 'Blftipr',
            "sScrollX": true,
            paging: false,
            autoWidth: false,
            "bScrollCollapse": true,
            buttons: ['excelHtml5', 'print'],
            columnDefs: [ {                    
                targets: 11,
                render: $.fn.dataTable.render.ellipsis()
            } ]


  • kthorngrenkthorngren Posts: 17,697Questions: 25Answers: 4,197

    Looking at the renderer code the first thing it does is return the original data for all orthogonal data types except display. The Orthognal data export example explains that exporting uses the display data. Based on this I see tow options.

    One option is to use orthogonal data as shown in that example to export the original data. To do this you will need to modify the plugin code to first check to see if the type === "export" and return the original data.

    The second option is to format the out like this example and have it return the original cell data, something like this:

    There maybe other options but those are the two I see.


  • allanallan Posts: 57,686Questions: 1Answers: 9,195 Site admin

    Between this thread and another recent one, I think there is a strong argument for changing the default orthogonal data export to be export...


Sign In or Register to comment.