It appears that using a custom formatter makes the cell stuck in the edit mode and previously edited row never gets restored.
JS, grid defined here
$(priceListGrid).jqGrid({
datatype: 'local',
url: common.getServerPath() + 'controller/action',
mtype: 'POST',
jsonReader: common.jqgrid.jsonReader('Id'),
colModel: [
{ name: 'MethodCode', label: 'MethodCode', index: 'MethodCode', hidden: true },
{ name: 'PriceCode', label: 'Price Code', index: 'PriceCode', width: '20px' },
{ name: 'Description', label: 'Description', index: 'Description', width: '34px' },
{ name: 'RoundTo', label: 'RoundTo', index: 'RoundTo', width: '10px' },
{
name: 'MinPrice',
label: 'Min Pr',
index: 'MinPrice',
width: '15px',
align: 'right',
formatter: customCurFormatter,
editable: true,
editrules: {
number: true,
minValue: 0,
custom: true,
custom_func: validateMinPrice
}
}
],
caption: 'Price Entity List',
hidegrid: false,
ignoreCase: true,
viewrecords: true,
recordtext: '{2} Entity(ies).',
autowidth: true,
shrinkToFit: true,
scroll: 1,
sortname: 'PriceCode',
sortorder: 'asc',
rowNum: 500,
altRows: true,
altclass: 'gridAltRowClass',
pager: '#pagerEntityPriceListDetails',
onCellSelect: priceItemSelect,
onSelectRow: onSelectPrice,
afterSubmitCell: function (rowid) {
this.setRowData(rowid, info.Data, null);
},
loadComplete: priceListEntityLoadComplete,
loadError: function (xhr, status, error) {
common.ajax.alsJsonError(xhr, status, error);
//stopDataLoading();
}//,
//loadBeforeSend: function () { isDataLoadingCount++; },
//beforeSelectRow: function () { return !getIsDataLoading(); }
})
this is the formatter
var customCurFormatter = function (cellvalue, options, rowObject) {
return cellvalue.toFixed(rowObject.RoundTo);
}
When it's used, as opposed to formatter:currency
, the cell is stuck in edit mode when going over to the next line.
Any ideas would be appreciated.
The current code of the custom formatter is wrong, because
toFixed
method could be applied toNumber
and not to string. Thecellvalue
hasString
type at least during editing. Minimal changes of the code of the formatter should beYou code has many other problems. For example, it's strictly recommended to define always unformat callback together with
formatter
.