beforeShowForm: function($form) {
setTimeout(function() {
$form.find('input#credit.FormElement').val(0);
},50);
}
works for me as when load the form i reset the value of Credit;
質問
hi i am using JQGrid and want to set value of a cell to zero when i edit the row and whatever the value of the cell is like if cell value is 103.50 i want to to set to 0 i try
editoptions:{dataInit : function (elem){$(elem).val("0");}}
and it works for only new but i want to reset value of cell to "0" even when i use form edit.
i also try
editoptions:{defaultValue:"0"}
and
editoptions:{value:"0"}
but all is working when use form edit for new row and when try to edit it show first time the default "0" value but when i cancel and again edit form then cell value is set in the text input field
i know its not logical but want to do for customer requirement and also search a lot for it but unable to find any related proper answer
解決 2
beforeShowForm: function($form) {
setTimeout(function() {
$form.find('input#credit.FormElement').val(0);
},50);
}
works for me as when load the form i reset the value of Credit;
他のヒント
I think you need to set the value of the cell, when selecting the row, if it an inline edit.
onSelectRow: function (id) {
if (id) {
selectedRowId = id; // save current row ID
var myCellData = grid.jqGrid('getCell', selectedRowId , 'MyColName');
}
},
where id the row id, then you can find the cell value
Hope this helps you. Enjoy jqGrid.