Open bughit opened 5 years ago
Thanks. I will investigate the problem as per your description.
However, if you do restore non editable, then formatting should be skipped, as they are already formatted.
This actually is not true. The savedRow object stores unformated values, when the row is edited. See here: https://github.com/tonytomov/jqGrid/blob/master/js/grid.inlinedit.js#L85
However, if you don't skip the formatting, then cellvalue and rowData should contain pre-format row data per the docs
When restore the row we use a setRowData method to which we pass the unformatted array of all values which will be formated (is any) when they are restored. see this code : https://github.com/tonytomov/jqGrid/blob/master/js/grid.base.js#L5223
I do not see any problem with this. Can you please post a demo explaining the problem?
I'm guessing from your links you're going to suggest to supply a custom unformatter? That's not a reliable solution to a problem that should not exist in the first place. There is no guarantee that formatting is reversible. If you know you'll be needing original data, you should hold on to it and not depend on unformatting.
<!DOCTYPE html>
<html lang="en">
<head>
<!-- The jQuery library is a prerequisite for all jqSuite products -->
<script type="text/ecmascript" src="https://code.jquery.com/jquery-3.4.0.js"></script>
<!-- We support more than 40 localizations -->
<script type="text/ecmascript" src="/assets/jqgrid/current/js/i18n/grid.locale-en.js"></script>
<!-- This is the Javascript file of jqGrid -->
<script type="text/ecmascript" src="/assets/jqgrid/current/js/jquery.jqGrid.js"></script>
<!-- A link to a Boostrap and jqGrid Bootstrap CSS siles-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="/assets/jqgrid/current/css/ui.jqgrid-bootstrap.css" />
<script>
$.jgrid.defaults.width = 780;
$.jgrid.defaults.responsive = true;
$.jgrid.defaults.styleUI = 'Bootstrap';
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<meta charset="utf-8" />
<title>jqGrid Loading Data - JSON</title>
</head>
<body>
<div style="margin-left:20px">
<table id="jqGrid"></table>
<div id="jqGridPager"></div>
</div>
<script type="text/javascript">
var mydata = [
{ id: "1", invdate: "2007-10-01", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" },
{ id: "2", invdate: "2007-10-02", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
{ id: "3", invdate: "2007-09-01", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00" },
{ id: "4", invdate: "2007-10-04", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" },
{ id: "5", invdate: "2007-10-05", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
{ id: "6", invdate: "2007-09-06", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00" },
{ id: "7", invdate: "2007-10-04", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" },
{ id: "8", invdate: "2007-10-03", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
{ id: "9", invdate: "2007-09-01", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00" }
];
$(document).ready(function () {
$("#jqGrid").jqGrid({
datatype: "local",
data: mydata,
height: 250,
colModel: [
{ name: 'actions', formatter: 'actions'},
{ label: 'Inv No', name: 'id', width: 75, key:true },
{ label: 'Date', name: 'invdate', width: 90 },
{ label: 'Client', name: 'name', width: 100 },
{ label: 'Amount', name: 'amount', width: 80 },
{ label: 'Tax', name: 'tax', width: 80 },
{
label: 'Total',
name: 'total',
width: 80,
formatter: function(cellVal, opts, rowData, action) {
return '$' + cellVal;
}
},
{ label: 'Notes', name: 'note', width: 150 , editable: true}
],
viewrecords: true, // show the current page, data rang and total records on the toolbar
caption: "Load jqGrid through Javascript Array"
});
});
</script>
</body>
</html>
Prior to the fix (71f25da0ad3159422413f5b83d3efbd23c29525a) for #819, non editable columns were not restored.