Javascript Decode Special Characters and Newline

Kasusnya kejadian di Kendo Grid. Di database disimpan >\n. Secara default ditampilkan di dalam Kendo grid > dan enter nya hilang.

Solusi menggunakan fungsi di bawah ini sebelum ditampilkan di grid.

[code language=”javascript”]
function FormatText(text) {
var textContainer = $("<div></div>");
textContainer.html(text.replace(/\n/g, "<br>"));
return textContainer.html();
}
[/code]

Chandra Oemaryadi has written 244 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>