Hi,
I have a UltraWebGrid where its values can be modified through the grid's Row Edit Template.
I have few columns in UltraWebGrid where each them has the DataType "System.Decimal". If the decimal values in these columns are too small, it displays an exponential value on the field in Row Edit Template.
For example:- If the value in the grid is 0.000001 (six decimals), then it'll populate 0.000001 onto the field in Row Edit Template. This is OK. - But, if the value in the grid is 0.0000001 (seven decimals), then it'll populate 1e-7 onto the field in Row Edit Template. Not OK.
Another wierd thing happens When I try to update the small decimal value back to the grid and trigger the "UpdateRow" server event. The value returned from the particular cell is "False" rather than the number itself. It's not even the number in exponential expression.
For example, in grid's UpdateRow event:If the cell value is 0.000001(six decimals), then e.Row.Cells(0).Value ==> 0.000001 (OK)
But, If the cell value is 0.0000001 (or 1e-7, seven decimals) e.Row.Cells(0).Value ==> False
Is this a bug?
So, my question is...For small decimal number,
1) Is there a way for me to display the actual number (not the exponential value) onto field in Row Edit Template?
2) And instead of "False", how can I get the modified number in grid's UpdateRow event?
Please don't tell me to change the column's datatype to String.
Hello!! Even i faced the same issue, it's a bug with the way the double precisions are handled in the control. I fixed the issue with few work around.
1) In InitializeGrid event i just changed the datatype to string(8).
for (var BandIndex = 0; BandIndex < GridControl.Bands.length; BandIndex++) {
var CurrentBand = GridControl.Bands[BandIndex];
for (var ColIndex = 0; ColIndex < CurrentBand.Columns.length; ColIndex++) {
var CurrentCol = CurrentBand.Columns[ColIndex];
if (CurrentCol.DataType == 14 /*Currency*/ || CurrentCol.DataType == 4/*Float*/ || CurrentCol.DataType == 5/*Double*/) {
CurrentCol.DataType = 8/*string*/; //to fix decimal point issue for lower value. For ex .00000045-> 45e-7
}
note: No worries it will allow only numbers
2)In AfterExitEditModeHandler just write this line.
CurrentlyUpdatedCell.setValue(CurrentlyUpdatedCell.MaskedValue);
It solved the problem..
Thanks.
Using client scripts, the grid's cell will return value in exponential format. Somehow in code behind, it changes to False. I think this is a bug with the control.
I am not going to play around with this issue anymore. I'll just change the grid column's data type to "String". Thank you for taking your time on responding this.
I'm not at this point as when we work with our numbers with lots of decimal places we do all updates from the grid via our own ajax object in the CSOM cell update event we capture the value and save it...
However, perhaps you should set up the cell update event and see what the javascript thinks the value is at that point...
function UltraWebGrid1_AfterCellUpdateHandler(gridName, cellId){
// get a reference to the cell var cell = igtbl_getCellById(cellId);
if(!cell) return;
// display the value... alert(cell.getValue()); return;}
Further note...have you changed or could change the cell format string for the column or webNumericEditor?
Thanks, but I am already using a WebNumericEdit control.
The problem is not on the number of decimal places it can support, but rather the Value of the decimal number.
For example agian...
if the decimal number is 20.00000000000000001. I have no problem getting 20.00000000000000001 form the grid's cell in code behind.
But, if the decimal number is 0.00000001, it will return "False" in code behind when you try to get the value from the grid's cell.
Use a WebNumericEditor and set the web grid column's editor to it. There should be some examples of how to do this...in one of our apps, we require display of at least 20 decimal places which the WebNumericEditor allows.
The editor also helps in that it validates the keys pressed and only allows numeric characters into the cell.