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 :)
Bunty,
I format the cells dinamically using a javascript code:
function HandleExitEdit(gridID,cellID) { var cell = igtbl_getCellById(cellID); var line = cell.getRow().getIndex(); var rows = igtbl_getGridById(gridID).Rows; var current_line = rows.getRow(line); var coluna = cell.Column.Key; if ((coluna == 'KEYOFCOLUMN') && (current_line.getCellFromKey('KEYOFCOLUMN').getValue() != "")&& (current_line.getCellFromKey('KEYOFCOLUMN').getValue() != null)) { var value = current_line.getCellFromKey('KEYOFCOLUMN').getValue(); //Type here a piece of code to format the string urrent_line.getCellFromKey('KEYOFCOLUMN').setValue(value); } }
And on uwg's propertie ClienteSideEvents set this:
<ClientSideEvents AfterExitEditModeHandler="HandleExitEdit" />
I hope this helpful.
Thank you for your help.
I have tried to use the above given workaround but it is not working in my case, as I have provided you with the format which I am using and I have tried to use the following workaround:
function HandleExitEdit(gridID,cellID) { var cell = igtbl_getCellById(cellID); var line = cell.getRow().getIndex(); var rows = igtbl_getGridById(gridID).Rows; var current_line = rows.getRow(line); var coluna = cell.Column.Key; if ((coluna == 'TestCol') && (current_line.getCellFromKey('TestCol').getValue() != "")&& (current_line.getCellFromKey('TestCol').getValue() != null)) { var value = current_line.getCellFromKey('TestCol').getValue();
//Type here a piece of code to format the string value = parseFloat(value) / 1000; // But this will change the column value + this will need to interchange when again try to access the //column Please suggest do I need to set column format from there?? current_line.getCellFromKey('TestCol').setValue(value); } }
I use a javascript function that receive a number and format and return a decimal:
function formatCurrency(num) { if(isNaN(num)) num = "0"; num = Math.round(num*100); cents = num%100; num = Math.floor(num/100).toString(); if(cents<10) cents = "0" + cents; for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3)); return (num + '.' + cents);}
After it's just use the function like this:
current_line.getCellFromKey('TestCol').setValue(formatCurrency(value)); } }
Hope this helpful.
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