Javascript 剑道模板在从函数调用时显示原始html
我正在使用剑道网格,我有一个函数,我正在使用它来获取一些Html,以便为我的一个colmumns呈现。我的代码如下所示:Javascript 剑道模板在从函数调用时显示原始html,javascript,jquery,html,kendo-ui,kendo-grid,Javascript,Jquery,Html,Kendo Ui,Kendo Grid,我正在使用剑道网格,我有一个函数,我正在使用它来获取一些Html,以便为我的一个colmumns呈现。我的代码如下所示: { field: "StateString", title: "State", width: "120px", encoded: true,
{
field: "StateString",
title: "State",
width: "120px",
encoded: true,
template: '#:GetFaClass(data.StateString)#'
}
function GetFaClass(status) {
if (status == 'Queued') {
return ('<i class="fa fa-folder" aria-hidden="true"></i>')
}
}
现在,当我们调用此函数时,它如下所示:
{
field: "StateString",
title: "State",
width: "120px",
encoded: true,
template: '#:GetFaClass(data.StateString)#'
}
function GetFaClass(status) {
if (status == 'Queued') {
return ('<i class="fa fa-folder" aria-hidden="true"></i>')
}
}
函数GetFaClass(状态){
如果(状态==“排队”){
返回(“”)
}
}
有趣的是,它确实调用函数并返回值,但随后将其显示为文本,而不是呈现html。现在,如果我不调用函数,而是硬编码如下所示的值,那么它会很好地呈现:
{
field: "StateString",
title: "State",
width: "120px",
encoded: true,
template: ('<i class="fa fa-folder" aria-hidden="true"></i>')
}
{
字段:“StateString”,
标题:“国家”,
宽度:“120px”,
对,,
模板:(“”)
}
我可能做错了什么?如果要呈现为HTML,则必须进行更改
template: '#:GetFaClass(data.StateString)#'
致:
您必须将冒号(:)更改为等于(=)