How to prevent html escaping in DataTable

How to prevent html escaping in DataTable

zmacomberzmacomber Posts: 3Questions: 1Answers: 0

Debugger code (debug.datatables.net):
https://debug.datatables.net/ezazoj

Description of problem:
We get our data from the server side for use in our DataTable. The server is sending back this data for a particular column: S&LTRP

When the DataTable is rendering that particular column, it renders it as S<RP

I want that column data to display as is as S&LTRP

How do I accomplish this on a data column?

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Hi,

    What you want to do is to actually add HTML escaping - at the moment the HTML characters are being rendered.

    Use the text helper method to do that.

    Allan

  • zmacomberzmacomber Posts: 3Questions: 1Answers: 0

    When I specify my "aoColumns" definition on this column like the following it's still coming back in the wrong format: { "mRender": $.fn.dataTable.render.text() }

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    If you can link to a page showing the issue I'd be happy to debug it.

    Allan

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    Allan's suggestion works here:
    http://live.datatables.net/heyanece/1/edit

    Since you are using a legacy form of the options are you using Datatables 1.9?

    Can you provide a link to a test case showing the problem?
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • zmacomberzmacomber Posts: 3Questions: 1Answers: 0

    It looks like it's a JSP problem rather than Datatables. I have further debugged and found Datatables is rendering the data correct in the JS console on Chrome. I then tested S&LTRP directly in a table on the JSP and it renders it as S<RP. Thank you all for your guidance.

Sign In or Register to comment.