Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put HTML into Slickgrid cell?

When I put <a href="#">Click</a> into slickgrid, I see the actual code "<a href="#">Click</a>", whereas I expect the link to be rendered.

I know I can do it by subscribing click event but is it restricted thing in SlickGrid?

like image 931
enesness Avatar asked Mar 23 '12 14:03

enesness


2 Answers

Write a custom formatter:

function myFormatter(row, cell, value, columnDef, dataContext) {
  return "<a href='#'>Click</a>";
}

and specify it in the column definition.

like image 154
Tin Avatar answered Oct 24 '22 18:10

Tin


From @RicardoStuven

Or use the defaultFormatter option to treat any value as HTML:

defaultFormatter: function (row, cell, value, columnDef, dataContext) { 
    if (value == null) return ''; 

     return value.toString(); 
} 
like image 32
Toby Allen Avatar answered Oct 24 '22 16:10

Toby Allen