I am using php to create the tabulator column definition array and I would like to assign a javascript function. This does not work:
array_push($row2['formatter']='function(cell, formatterParams){var pType = cell.getValue();if(pType == "Patient"){cell.getElement().style.background = "yellow";}return pType;}');
I can assign the function to the array after using client side javascript. This works:
tdata[0][1]['formatter']=function(cell, formatterParams){var pType = cell.getValue();if(pType == "Patient"){cell.getElement().style.background = "yellow";}return pType;};
Any help making this work on the server side with php would be greatly appreciated!
I came up with this solution... I'm sure there is a better way to do it!
function returnFunc(value, index, array){
if (value['formatter']){
if (value['formatter'].indexOf("function")>-1){
return value['formatter']=eval("(" + value['formatter'] + ")");
}
}
}
tdata[0].map(returnFunc);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.