#104589
Peter
Participant

I’m still having difficulties making this work.

If I use the approach with creating a template (if it doesn’t exist) with DIVs and then setting textContent, then I get the font-awesome icon markup (<i>…</i>) as text in the field, which is not the desired result.

If I use empty string ” as template (if no icon should be shown) and font-awesome icon markup if a icon should be shown, then it works the first time at least, going from no icon to an icon.
But when the value is changed so there should be no icon again, then it doesn’t work – the icon stays.

In the sample below ImageAvailable == false should show no icon in File, while ImageAvailable == true should show an icon in File.
So what I’m trying to switch between is either ” or ‘<i class=”some-font-awesome-font”></i>’.

`{
label: ”, dataField: ‘File’, cellsVerticalAlign: ‘middle’, verticalAlign: ‘middle’, align: ‘center’, cellsAlign: ‘center’, width: 120, freeze: ‘far’,
allowEdit: false, template: function (formatObject)
{
const data = formatObject.row.data;

console.log(‘data.ImageAvailable: ‘ + data.ImageAvailable);

if (!formatObject.template)
{
console.log(‘formatObject.template == null’);
formatObject.template = ”;
}

if (data.ImageAvailable == false)
{
formatObject.template = ”;
}
else if (data.ImageAvailable == true)
{
formatObject.template = ‘<i class=”some-font-awesome-icon”></i>’;
}
}
},
{
label: ”, dataField: ‘ImageAvailable’, width: 70, allowEdit: true, visible: true
}`

screenshot

  • This reply was modified 1 year, 6 months ago by Peter.
  • This reply was modified 1 year, 6 months ago by Peter.
  • This reply was modified 1 year, 6 months ago by Peter.
  • This reply was modified 1 year, 6 months ago by Peter.