据我所知,columns.command甚至没有记录使用模板:尽管它有效。您可以执行以下操作:
columns : [
{
command: {
template : "# console.log('this', this); console.log('data', data); # toto"
}
},
...
]
甚至喜欢:
command: {
template : function (arg) {
console.log("this" ,this);
console.log("arg", arg);
console.log("data", data);
return "toto";
}
}
但是模板返回的内容必须是 astring并且在浏览器的控制台中您会看到 ,是this对象并且是包含网格数据的。windowargcommanddataarray
虽然您可以包含额外的参数:
command: {
template : function (arg) {
console.log("this" ,this);
console.log("arg", arg);
console.log("arg.a", arg.a);
console.log("data", data);
return "toto";
},
a: "extra argument"
}
我在其中添加了一个额外的a参数,arg.a您仍然无法访问当前行data,因为该元素仍未插入。
而不是我建议做的事情是:
columns : [
{
title: " ",
template: "#= myVariable# #if(myBoolean) {# <img src='/images/myImage.png' /> #}#"
},
...
]
您不需要将其作为命令,对吗?为什么需要它作为命令?