JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Data Grid › Change cell value based on other cell value › Reply To: Change cell value based on other cell value
Hi,
This is happening because you initially set the template to an empty div element.
You should have your conditionals initially also.
The correct code is this below:
const data = formatObject.row.data;
if (!formatObject.template) {
if (data.attachment_count != null) {
if (data.attachment_count < 1) {
formatObject.template = ‘<div></div>’;
}
else if (data.attachment_count == 1) {
formatObject.template = ‘<div><some fa icon A></div>’;
}
else if (data.attachment_count > 1) {
formatObject.template = ‘<div><some fa icon B></div>’;
}
}
else {
formatObject.template = ‘<div></div>’;
}
} else {
if (data.attachment_count != null) {
if (data.attachment_count < 1) {
formatObject.template.innerHTML = ”;
}
else if (data.attachment_count == 1) {
formatObject.template.innerHTML = ‘<some fa icon A>’;
}
else if (data.attachment_count > 1) {
formatObject.template.innerHTML = ‘<some fa icon B>’;
}
}
else {
formatObject.template.innerHTML = ”;
}
}
Best Regards,
Svetoslav Borislavov
Smart UI Team
https://www.htmlelements.com/
- This reply was modified 1 year, 9 months ago by svetoslav_borislavov.
- This reply was modified 1 year, 9 months ago by svetoslav_borislavov.