Hello
I am trying to format a cell in iggrid. The cell value is of a double value and is formatted with (format: 'currency').
Here is what I see:
- When Amt is < 0 and
- When using this in grid { headerText: 'Amount' , key: 'Amt', dataType: 'number' , template: '{{if ${Amt} < 0}} print this {{else}} print that {{/if}}'}, format: 'currency' },
'print that' gets printed.
- When using this in grid { headerText: 'Amount' , key: 'Amt', dataType: 'number' , template: '{{if ${Amt} < 0}} print this {{else}} print that {{/if}}'} }, // (note the removal of "format: 'currency'")
'print this' gets printed.
I am assuming that when the template trying to resolve this it takes the 'formatted' value (in this case with $ sign and () if negative) and try to resolve it but it returns always false. Is there a way to fix this.
Thanks
Herald
Hello Herald,
Yes, your observation is correct. The format is evaluated before the template and what template sees is the value currency symbols in it.
If you want to have a greater flexibility in formatting cells you should use a column formatter like this:
{ headerText: 'Amount' , key: 'Amt', dataType: 'number' , format: 'currency', formatter(val,row) {
if (val < 0) {
return $.ig.formatter(val, "number", "currency");
}
return val;
Hope this helps,Martin PavlovInfragistics, Inc.