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.
In my case I wanted t apply both formatting like turn for ex. 1.23 to $1.23 and apply a specific CSS style for ex. $1.23 for val > 0 and $1.23 for val <= 0.
I'm attaching a sample demonstrating how you can achieve this scenario.
Let me know if you have further questions regarding this subject.
Best regards,Martin PavlovInfragistics, Inc.
Hi Martin
I am looking for very urgent quick help
i have columns applied currency format, is there any way to have one column with two decimal which is default but another column with three decimal and another with four decimal.
I understand that $.ig.regional.defaults i have to set min/max value for currency, suppose i set min to 0 and max to 9 and but how can we set dynamically column decimal value to according to my need for each column.
How can I achieve that.
I felt $.ig.formatter this can help me but didn't understand this function completely, since its not mentioned any documentation can you help me to understand this function.
I tried this but didn't worked $.ig.formatter(9332.44567889, "number", "currency",null,null,'0.00')
Your ASAP response will be very helpful for me.
Sorry i forgot to mentioned i don't want to loose datatype, I didn't want to loose currency(number) sorting and filtering
HI Martin
Its very disappointing. I am using your licensed version and hence expecting a response from you ASAP. i have some client deliverable which is getting delayed because i am not getting any response from Team.
It will be very help full you Response on this ASAP.