Is there a way to apply ellipsis for rendered column ?

Is there a way to apply ellipsis for rendered column ?

smeghzifensmeghzifen Posts: 1Questions: 1Answers: 0

Hi everybody,
I want to to apply ellipsis for rendered column as bellow ?

$('#tableID').DataTable({
columns: [
{
"data": "profils", // column index number 2.
"render": "[, ].name" // building string with comma separator.
},
...
],

columnDefs: [
{
targets: 2,
render: $.fn.dataTable.render.ellipsis(5)
}
],
...
}

Answers

  • allanallan Posts: 63,813Questions: 1Answers: 10,517 Site admin

    You need to combine the two renderers together. A column can only have a single rendering function, so you would need to do something like:

    render: function ( data, type, row ) {
      if ( type === 'display' ) {
        var myRenderedValue = // do your rendering / joining
    
        return $.fn.dataTable.render.ellipsis(5).display( myRenderedValue );
      }
      return data;
    }
    

    Regards,
    Allan

This discussion has been closed.