Hello,
I want to give a cell a value if its empty.
How would be the best way of doing that condition?
Thank you and regards.
Use cell formatter.
e.g.
https://gist.github.com/gridphp/b86f17429c67ac7c5166ff7ccb9376d2
Line 104,142
It was just for demo code to make similar. I think following should work.
PHP:
$col["formatter"] = "function(cellval,options,rowdata){ return formatField(cellval,options,rowdata); }";
$col["unformat"] = "function(cellval,options,cell){ return unformatField(cellval,options,cell); }";
JS:
<script>
function formatField(cellval,options,rowdata)
{
if(cellval === undefined || cellval === 'NULL' || cellval === '')
return '-';
return cellval;
}
function unformatField(cellval,options,rowdata)
{
if(cellval === '-')
return '';
return cellval;
}
</script>