Access to data returned from the server

I am looking for access to the actual value returned from the server. getRowDatareturns a value after unformat is applied to the value. This leads to loss of information.

For example, if a double value is rounded to two decimal places, and if I want to fill out a form for editing with the original value returned from the server with 6 decimal places, how can I get the return value.

eg:

Value returned from the server: 12.345678

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

The value is displayed in the grid: 12.35

How to get the value returned from the server 12.345678. getRowDatareturns 12.35

I am using json data returned from server. Using firebug, I confirmed that the server returns all 6 decimal places. Its only when extracting the value from the selected line in which decimal places are truncated.

+3
source share
1 answer

You can use unformatto get the initial value for methods such as getRowData. The Custom Formatter section provides more information on 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 can simply take the original value (with more than two decimal places) and return it.

+1
source

Source: https://habr.com/ru/post/1738481/


All Articles