如何将javascript函数分配给使用php呈现的制表器格式化程序?
我正在使用php创建制表器列定义数组,我想分配一个javascript函数。 这不起作用:如何将javascript函数分配给使用php呈现的制表器格式化程序?,javascript,php,tabulator,Javascript,Php,Tabulator,我正在使用php创建制表器列定义数组,我想分配一个javascript函数。 这不起作用: array_push($row2['formatter']='function(cell, formatterParams){var pType = cell.getValue();if(pType == "Patient"){cell.getElement().style.background = "yellow";}return pType;}'); 我可以在使用客户端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);