Hi
I am seeing some odd behaviour. I have two cells which are of the Decimal data type. I can confirm this to be true because when do the following:?this.ultraGridMain.DisplayLayout.Bands[0].Columns[col.Name].DataType
they both are decimals, as they should be because the underlying table column is decimal.
I formatted them as "F2" as follows:
this.ultraGridMain.DisplayLayout.Bands[0].Columns[col.Name].Format = "F2";
I only want the user to see a maximum of 2 decimal places. Which does happen, under certain circumstances which is not good as follows:
When the form opens if i click in a cell:
now, if i change the cell value to a number with no decimals as follows, when i click back on i see no decimals, i am fine with this
now if i change it again and put in decimal places, leave the cell then go back, i only see the two decimal places, which is what i wanted to see when i opened it in the first picture above but didn't:
Now, I will do the same thing again but when i change the figure I will change it to one with decimals
Form is opened, click on cell and see all the decimal places:
Change the decimals
Click back into the cell and this time it shows all the decimals again:
That is inconsistent. If I change the number to one with no demical places then from then on in I only see 2 decimal places, but if i change it to one with decimal places it continues to show all the additional zeros. n.b. underlying data is decimal (28,10) hence 10 decimal places. However, the main point here is the inconsistency in the grid.Please can you explain how I get that to always be 2 decimal places? I am happy to display none when the number entered has none but I do not want to see 10 decimal places sometimes and not others, it should always be 2.
Thanks
Paul
They are different numbers, that is correct but different rows could have different decimal places. It is basically currency values that the users are entering, so in GBP they have 2 decimal places and in JPY i think it is 3 and so on.
What we do is show it rounded by two because the most common are 2 decimal places but they are allowed to insert more, the database behind allows 10. We could, if i wanted to take it further, display each rows monetary value to the correct decimal places of the country of the chosen currency on that row, but that is a step too far as I am simply replicating how it works in the application we are migrating from. Maybe one day ;)
Hello,
I am glad to hear that you have found a solution that answers to your needs.
However, please note that 123,456,789,876.01928 and 123,456,789,876.20 are not the same numbers, and I'm pretty sure that formatting should not change the number(at least it doesn't on my end).
If you would like to allow an user to input 123,456,789,876.01928 and then on the consequential edit the value to be 123,456,789,876.20, you can hook to AfterCellUpdate, and do Math.Round on the number to the second decimal.
Thank you for using Infragistics components.
Sincerely,Tihomir TonevAssociate Software DeveloperInfragistics
EDIT: Can skip all the writing as after 4 hours of faffing around I found a simple fix noted at the bottom
Basically, I want users to be able to input as many decimal places as they need. The field type in SQL is Decimal 28,10.
Some places they would only need to insert 2 decimal places, others they might insert more but I only want to display 2 so therefore the values:
123,456,789,876.01928
123,456,789,876.02
would both be valid but only show the rounded value in the second amount above.
the numeric editor seems a bit limited at first look, maybe it requires a specific format type, or is this not even possible?
Here are some screenshots to show what I mean but I want to display 2 decimal places but allow more if necessary
User types many decimals:
once they are finished editing they see only two
I cannot just limit them to 2 decimal places, and I don't want them to see a number like this if they don't even use any: 32.00000000, when there are no decimals included then it should have a .00.
The form the user is inputting data into is for currency transactions, but not specific to their locality, so on one row they may input USD and only require 2 decimals but on another they could input JPY which has 4 decimals so we want all rows to allow many decimals yet only display 2 after leaving the cell. Maybe we have to change the format on entry and leave?
I have so far managed to get to this, but it is doing what I want the wrong way around, so when I am not in the numeric editor I see this:
but when i click into it then it changes to this
I hope I make sense
EDIT (FIX):
After 4 hours it seems all i needed to get to where i wanted was:
this.ultraGridMain.DisplayLayout.Bands[0].Columns[col.Name].Format = "n2";
That is certainly the best I can get and will do.
.Format does not apply to the cell in edit mode. For this you can use a mask or assign an UltraNumericEditor for the cell.
If your requirement is to limit input to up to 2 decimals, you can do:
this.ultraGrid1.DisplayLayout.Bands[0].Columns[ColumnName].MaskInput = "nnnnnnnnnnn.nn";
The downside of this is that you cannot assign masks for negative and positive entries as you would do with formatting.
Should you have further questions, please let me know.
SIncerely,Tihomir TonevAssociate Software DeveloperInfragistics