Hi !!!
I am facing unexpected issue with UltraWebGrid. I have set number format on the Grid's column using column's format property and now using setValue and by GUI inputing new value to the grid's cell and it is not taking the format given at the server side using following code snippet : Format = "###,##0,";
Am I doing something wrong there or is it expected behavior ???? I have also tried with Editors but not working
Bunty :)
I'm having the same problem as the original poster. I have a column with a mask of "#,###,###". The column has decimal data. If a cell has a value of 90.5 when bound to the datasource, it is correctly formatted, rounded, and displayed as 91.
HOWEVER, if I use the cell.setValue() method to set the same cell to 90.5, the setValue() method incorrectly applies the format and displays a value of 90. If the data is saved and the grid re-bound, the grid correctly displays 91. In my case, the user makes an edit to a column which updates another calculated column. However, the calculated value displayed is wrong because of this rounding error until they save and the refresh the grid.
The supposed work around above to format the data before calling setValue is unacceptable. That would change the actual data value. Continuing with the above example, I don't want to save the value 91. I need to save 90.5, and just have it display 91 (which is what it does correctly when the bound data is formatted initially).
Contrary to the post above, setValue() does NOT correctly apply the format if one already exists on the column. It partially applies the format, but rounding is not handled appropriately.
At this point, the only work arounds I can come up with is to have another hidden column with the actual calculated value and then format the display value in a separate displayed column or to redo the calculations on the server side before saving the data. Both of these options are, of course, absurd. I shouldn't have to do this. The infragistics setValue() method should use the column's formatting and should round correctly, but it just doesn't. This appears to be a bug.
Hi Bunty,
As the method says "setValue(cellValue)", it sets the value of the cell. If a format for this cellValue is already defined, then it sets the format too. Only the format of the cell without specifying the value cannot be set with this method. To set the format, you have to apply your own logic. For example, here is how I'm formatting a cell value:
function UltraWebGrid1_InitializeLayoutHandler(gridName)
{
var row = grid.Rows.getRow(0);
var cell = row.getCellFromKey("ID");
var num = 50000;
cell.setValue(num.toFixed(4)); //Sets the value of the cell to 50000.0000
}
I would suggest to go through the links I referred in an earlier post to this thread. Here is another helpful link on formatting numbers in javaScript.
http://www.mredkj.com/javascript/numberFormat.html
Hope this helps.
Sarita
still there is no update ?????
Sarita,
One more thing I would like to ask does Infragistics supports setValue with the format of the column which I have set and also let me know Infragistics code actually tries to set the format.
It is not working with my code if possible please let me know with sample code.
Hi,
I have tried your approach but it fails to help me on the issue when I try to set the value using setValue on the client side it change the cell value instead of format and when I try to access the cell value it returns the value which I have set using setvalue example:
1000000/1000 = 100 I have set using setValue and the above given function which I have used and when I try to fetch the cell value and try to save it into the database it returns the value which I have set using setValue however I want to set it as format instead of value of the cell. I hope you can understand this