This example works fine.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="https://www.jeasyui.com/easyui/themes/icon.css">
<script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.min.js"></script>
<script type="text/javascript" src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="https://www.jeasyui.com/easyui/datagrid-cellediting.js"></script>
<script>
var data = {
"total": 28, "rows": [
{ "productid": "FI-SW-01", "productname": "Koi", "unitcost": "10.00", "status": "P", "ilosc": "36.50", "attr1": "Large", "itemid": "EST-1" },
{ "productid": "K9-DL-01", "productname": "Dalmation", "unitcost": "12.00", "status": "P", "ilosc": "18.50", "attr1": "Spotted Adult Female", "itemid": "EST-10" },
{ "productid": "RP-SN-01", "productname": "Rattlesnake", "unitcost": "12.00", "status": "P", "ilosc": "38.50", "attr1": "Venomless", "itemid": "EST-11" },
{ "productid": "RP-SN-01", "productname": "Rattlesnake", "unitcost": "12.00", "status": "P", "ilosc": "26.50", "attr1": "Rattleless", "itemid": "EST-12" },
{ "productid": "RP-LI-02", "productname": "Iguana", "unitcost": "12.00", "status": "P", "ilosc": "35.50", "attr1": "Green Adult", "itemid": "EST-13" },
{ "productid": "FL-DSH-01", "productname": "Manx", "unitcost": "12.00", "status": "P", "ilosc": "158.50", "attr1": "Tailless", "itemid": "EST-14" },
{ "productid": "FL-DSH-01", "productname": "Manx", "unitcost": "12.00", "status": "P", "ilosc": "83.50", "attr1": "With tail", "itemid": "EST-15" },
{ "productid": "FL-DLH-02", "productname": "Persian", "unitcost": "12.00", "status": "P", "ilosc": "23.50", "attr1": "Adult Female", "itemid": "EST-16" },
{ "productid": "FL-DLH-02", "productname": "Persian", "unitcost": "12.00", "status": "P", "ilosc": "89.50", "attr1": "Adult Male", "itemid": "EST-17" },
{ "productid": "AV-CB-01", "productname": "Amazon Parrot", "unitcost": "92.00", "status": "P", "ilosc": "63.50", "attr1": "Adult Male", "itemid": "EST-18" }
]
}
$(function () {
$('#dg').datagrid({
data: data,
columns: [[
{
field: 'ilosc',
title: 'Ilość',
width: '100px',
halign: 'center',
align: 'right',
editor: {
type: 'numberbox',
options: {
precision: 3,
decimalSeparator: ',',
formatter: function (value) {
if (value) {
value = parseFloat(value);
}
value += '';
const dpos = value.indexOf('.');
if (dpos >= 0) {
const s1 = value.substring(0, dpos);
const s2 = value.substring(dpos + 1, value.length);
return s1 + ',' + s2;
} else {
return value;
}
}
}
},
formatter: function (value) {
if (value) {
value = parseFloat(value);
}
value += '';
const dpos = value.indexOf('.');
if (dpos >= 0) {
const s1 = value.substring(0, dpos);
const s2 = value.substring(dpos + 1, value.length);
return s1 + ',' + s2;
} else {
return value;
}
}
},
]],
idField: 'id',
rownumbers: true,
singleSelect: true,
onSelect: function (index, row) {
$(this).datagrid('unselectRow', index);
},
onBeforeEdit: function (index, row) {
$(this).datagrid('refreshRow', index);
},
onEndEdit: function (index, row) {
if (parseFloat(row.ilosc) <= 0) {
row.ilosc = 1;
}
},
onAfterEdit: function (index, row) {
$(this).datagrid('refreshRow', index);
},
onCancelEdit: function (index, row) {
$(this).datagrid('refreshRow', index);
}
}).datagrid('enableCellEditing');
})
</script>
</head>
<body>
<table id="dg" class="easyui-datagrid" title="Editing in DataGrid" style="width:700px;height:auto" data-options="
singleSelect: true,
"></table>
</body>
</html>