views:

95

answers:

1

I am looking to access the actual value returned from the server.getRowData returns the value after unformat applied to the value. This results in loss of information.

For instance, if a double value is rounded to two decimal places and if I want to populate the form for edit with the original value returned from the server with 6 decimals, how can I get the value returned.

for eg:

Value returned from server : 12.345678

formatter option for column : formatter: 'number', formatoptions: {thousandsSeparator: ",", decimalPlaces: 2}

Value displayed in grid : 12.35

How do I retrieve the value 12.345678 returned from the server. getRowData returns 12.35

I am using json data returned from the server. Using firebug I have confirmed that the server returns all 6 decimal places. Its only when retrieving the value from selected row that the decimal places are truncated.

+1  A: 

You can use unformat to get the original value, for methods such as getRowData. There is more information in the Custom Formatter section of the jqGrid wiki. In particular they include the following example:

<script>
jQuery("#grid_id").jqGrid({
...
   colModel: [ 
      ... 
      {name:'price', index:'price', width:60, align:"center", editable: true, formatter:currencyFmatter},
      ...
   ]
...
});

function currencyFmatter (cellvalue, options, rowObject)
{
   // do something here
   return new_format_value
}
</script>

So in your unformatter you should be able to just take the raw value (with more than 2 decimal places) and return it.

Justin Ethier
The `unformat` still does not return the original data, especially with the fractions. This does not seem to be possible at the moment so I have resorted to pulling the necessary information from the server. I have also opened a feature request in the support forum.
Vinodh Ramasubramanian