How to put HTML into Slickgrid cell?

落花浮王杯 提交于 2019-12-06 03:52:30

问题


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?


回答1:


Write a custom formatter:

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

and specify it in the column definition.




回答2:


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(); 
} 


来源:https://stackoverflow.com/questions/9840548/how-to-put-html-into-slickgrid-cell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!