datables cant print values like a

datables cant print values like a

babablacksheepbabablacksheep Posts: 41Questions: 23Answers: 0

Dear Allan,
I have column where I need to print values like a<b but datables prints only a.
Please Provide fix or suggestion for this. I dont want to write it with spaces like a < b ..which seems to work

JSFIDDLE:
https://jsfiddle.net/bababalcksheep/8vpg6dp6/13/

var dataSet = [
    [ "State-1", "a<b" ],
    [ "State-2", "c<d" ] 
];
 
$(document).ready(function() {
    $('#example').DataTable( {
        data: dataSet,
        columns: [
            { title: "State" },
            { title: "Value" } 
        ]
    } );
} );

Answers

  • glendersonglenderson Posts: 231Questions: 11Answers: 29
    edited February 2016

    the < and > are valid HTML element open and close tags. You should be escaping them in your code. They should be &gt; and &lt; or similar.

    Here's a fun example of what happens when you don't escape your code.

    https://jsfiddle.net/glenderson/23xLq45q/

    Click the Make Me King example.

    When I pass a < or > I want them to be HTML element tags. If I want the < or > sign, I must use the escape characters instead.

This discussion has been closed.