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
March 14, 2023 at 11:18 am
#104509
Peter
Participant
Using the custom example was just want I was looking for. However, it is behaving a but odd.
I have 13 rows where only 1 row has CellA = 2 and the rest have CellA = 0.
I’m trying to change the content of CellB based on this value.
So I’m doing the following on CellB column:
{
label: '', dataField: 'CellB', cellsVerticalAlign: 'middle', verticalAlign: 'middle', align: 'center', cellsAlign: 'center', width: 80, freeze: 'far', allowEdit: false,
template: function (formatObject)
{
const data = formatObject.row.data;
console.log('data.CellA: ' + data.CellA);
if (data.CellA == 0)
{
formatObject.template = '';
}
else if (data.CellA == 1)
{
formatObject.template = '(font awesome icon X)';
}
else if (data.CellA > 1)
{
formatObject.template = '(font awesome icon Y)';
}
}
}
What I can see in the console is that the console.log line is fired 13 * 13 times.
(‘data.CellA: 2’ 1 time and ‘data.CellA: 0’ 12 times) * 13.
The method that “Smart('#grid', class ... etc. etc.
” is called only once though, so what could be going on here?