I have a grid with a value in a predefined field, I want to do it is to click edit a row want to change the value of one of the fields in the FormEdit.
The ColModel is:
colModel:[
{name:'id',index:'ID', width:50, hidden:true, search:false, editable:false,resizable:false},
{name:'product',index:'product', align:"center", width:20, search:false, editable:false,resizable:false},
{name:'volume',index:'volume', align:"center", hidden:false, width:15, search:false, editable:true}
],
I would establish volume = 1 when open the edit form, and i do like this...
ondblClickRow: function(id){
jQuery("#products").jqGrid('editGridRow', id, {
recreateForm:true,
beforeShowForm: function(form) {
$('#tr_volume',form).show();
$("#tr_volume",form).val('1');
},
reloadAfterSubmit:false, closeOnEscape:true, closeAfterAdd:true, closeAfterEdit:true,
editable:true, editrules:{edithidden:true,required:true,number:true,minValue:1}
})
But it's not working for me, what is wrong?
You don't use hidden: true
property of volume
column. So the setting $('#tr_volume',form).show()
is unneeded. The setting of $("#tr_volume",form).val('1')
is wrong, because the <tr>
element have no value. I think that you need jusu use $("#volume",form).val('1')
or $("#volume").val('1')
instead. The <input>
field with the id="volume"
(the same id like the column name) will be created in the form. It's the field which you probably try to change.