Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82227

Parsing "\n" new lines in HTML from JSON string.

$
0
0

So, a little background. I have a datatable set up, it's really rough around the edges, just to display a whole bunch of data from a JSON database. This is how I have it set out

$(document).ready(function() {
    $('#data').DataTable( {
        "ajax": {
            "dataType": 'json',
            "url": "domains.json",
            "dataSrc": "cards"
        },
        "order": [ 3, "desc" ],
        "columns": [
            { "data": "name" },
            { "data": "desc"},
            { "data": "shortUrl",
              "render": function(data, type, row, meta)
              {
                if(type === 'display')
                {
                    data = '<a class="trello-link" target="_blank" href="' + data + '">' + data + '</a> \n Open in Incognito';
                }

                return data;}
            },
            {  "data": "dateLastActivity"}
        ]
    } );
} ); 

And this is pulling information from the JSON database source. The data in the second column "desc" is a string that displays as such in the JSON:

"Some information here\nMore information here\nNext information here"

The "\n" when parsed through into the datatable doesn't form a new line, is there any way this can be performed without major changes to the database structure itself?

Kind Regards,
Ben


Viewing all articles
Browse latest Browse all 82227

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>