SlickGrid icon indicating copy to clipboard operation
SlickGrid copied to clipboard

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

Open laxmanp opened this issue 9 years ago • 2 comments

Hello sir,

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

laxmanp avatar Feb 01 '16 09:02 laxmanp

Convert your HTML to Text and then display it.

tobya avatar Feb 04 '16 21:02 tobya

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.

6pac avatar Feb 05 '16 00:02 6pac