We are displaying a grid with some fake data in it and we want to show the summary column as a percentage with a precision of 2 decimals places. We have the value showing up but how do I format the value to read:
-67.68%
Right now it omits the percent sign. I've tried the "rowDisplayLabel" but that is more of a prefixing. I tried different format values like "{0:P2}" but that didn't work either.
settings.ColumnSetting().ColumnKey("CompensationPercentageOver").AllowSummaries(true).SummaryOperands(x => { x.SummaryOperand().Type(SummaryFunction.Custom).Active(true).Format("{0:2}").RowDisplayLabel("").SummaryCalculator("calculateCompensationPercentageOver"); });
The column is setup as a normal column as a number.
For extra brownie points - is there any way to show specific values in a different color? Like negative values should be red while positive values should be in black. Thoughts?
Hello Karthik,
Thank you for sharing your experience in the community. I am glad that you achieved your requirement using the flexibility of the Summaries feature.
Thank you for using Infragistics components.
I got it working now. The reason for the initial trouble was because depending on the data that was loaded it needed to represent decimals based the type of location. Some areas see it with 2 scale precision while the rest round to the nearest whole number. I set this value in javascript using Razor code but I needed to reference it when painting the cell or rendering the percentage value.
I solve this, I had to manually override the renderSummaryCell event and I created my own implementation for rendering those cells.
It allowed us to paint the values in red if they were negative. This was the only way to provide that custom functionality and I am grateful that your tool allowed such customization.
Can you please provide me some additional information regarding your scenario.
What are the custom conditions under which you would like to set the zero precision? Is it that you are calculating the values for this column at runtime and in case that the value is equally dividable by 100 you would like to set the zero precision and in all cases other cases to set the precision to 2?
Additionally, can you please provide me the "calculateCompenstationOver" function code.
This information is going to be highly appreciated and will help me investigate this matter further.
Looking forward tp hearing from you.
I've been trying to post an update but the forum is failing for some reason. My approach actually won't work because under certain conditions I need to control the precision which I am struggling to do. How do I set the precision to zero?
I am glad that you manager to achieve your requirement.
Please let me know if you need any further assistance with this matter.