Having trouble combining render functions

Having trouble combining render functions

cj1005cj1005 Posts: 142Questions: 45Answers: 1

I have a textarea within my datatable and I currently use the ellipsis renderer to limit the initial display to 70 characters, but I also need to make sure 'carriage returns' and 'line feeds' are respected as well, I can do this by replacing \n or \r with <br> which works fine, but I do not know how to combine these two as one line.

The two separate working renders are as follows:

, render: $.fn.dataTable.render.ellipsis(70, true, true)

or

, render: function(data) { return data.replace(/(?:\r\n|\r|\n)/g, '<br>') }

So, could someone please tell me how to write the above two lines into one line of code?

Thanks, Chris

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,177Questions: 1Answers: 2,590
    edited March 2022 Answer ✓

    This example here is doing something similar to that. It calls the ellipsis() function first, then doing other stuff with the string,

    Colin

  • cj1005cj1005 Posts: 142Questions: 45Answers: 1

    Thank you Colin :)

Sign In or Register to comment.