mleibman / SlickGrid

A lightning fast JavaScript grid/spreadsheet
http://wiki.github.com/mleibman/SlickGrid
MIT License
6.81k stars 1.98k forks source link

How to display html text as plain text in SlickGrid column. #1107

Open laxmanp opened 8 years ago

laxmanp commented 8 years ago

Hello sir,

I want to display html text as plain text in grid column, so how to display.

tobya commented 8 years ago

Convert your HTML to Text and then display it.

6pac commented 8 years ago

Create a formatter that just takes the data text and returns it. Then pass the formatter in that column definition.

The default formatter is:

function defaultFormatter(row, cell, value, columnDef, dataContext) {
  if (value == null) {
    return "";
  } else {
    return (value + "").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
  }
}

which has limited HTML escaping. Just change the last return to: return value; to return the HTML as-is.