![](/img/trans.png)
[英]Missing formatter when using setColumns function in Tabulator 4.9
[英]How to assign a javascript function to a tabulator formatter rendered with php?
我正在使用 php 创建制表符列定义数组,我想分配一个 javascript 函数。 这不起作用:
array_push($row2['formatter']='function(cell, formatterParams){var pType = cell.getValue();if(pType == "Patient"){cell.getElement().style.background = "yellow";}return pType;}');
使用客户端 javascript 后,我可以将函数分配给数组。 这有效:
tdata[0][1]['formatter']=function(cell, formatterParams){var pType = cell.getValue();if(pType == "Patient"){cell.getElement().style.background = "yellow";}return pType;};
任何使用 php 在服务器端完成这项工作的帮助将不胜感激!
我想出了这个解决方案......我相信有更好的方法来做到这一点!
function returnFunc(value, index, array){
if (value['formatter']){
if (value['formatter'].indexOf("function")>-1){
return value['formatter']=eval("(" + value['formatter'] + ")");
}
}
}
tdata[0].map(returnFunc);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.