I am using jqgrid for listing and basic crud operations. On one of the pages there are many nullable fields present on the form. When some values are left blank when adding the entity, it saves those fields in db with null (which is fine). But when same field is edited in jqgrid edit popup, textboxes for these fields contain . How can I solve this problem
below figure is the update dialog that appears when I click a row in grid and select edit
UPdate 2
I don't have jqgrid.editform.js but the code Oleg mentioned was directly present in jquery.JQGrid.min.js. I removed the lines and now that code looks like
switch(C[G].edittype)
{
case "password":
case "text":
case "button":
case "image":
case "textarea":
if(A==" "||A==" "||(A.length==1 && A.charCodeAt(0)==160)) {
A = "";
alert("here");
}
alert(A);
a("#"+r,"#"+v).val(A);
break;
case "select":
I have put two alert messages to check if the code path is executed but I found no alert when running the page. What could be wrong here.
Thanks
I suppose you should just use the corresponding editoptions option to solve the problem:
UPDATED: If I understand correctly your problem now you can use
beforeSubmit
oronclickSubmit
callback of form editing to modify or to delete all empty values from thepostdata
parameter. You can for example usefor-in
loop to enumerate all properties ofposdata
. If the value of some parameter is empty you can usedelete
to remove the property or use= null
to change empty string tonull
. In both cases you should havenull
as the values of empty editing values.UPDATED 2: The version 3.6.5 which you use is really very old. Fortunately I have the version of jqGrid in my archive. I hope that the reason of your problem is bug in the old version of the code. If you use non-minimized version of jqGrid you can open
grid.formedit.js
file and remove lines 832-833:between
case "image":
andcase "textarea":
. The code should look like in the current version of jqGrid: see here. To fix the problem in minimized version of jqGrid you should search for the textcase "button":case "image":
and removea("#"+r,"#"+v).val(A);break;
which is directly aftercase "button":case "image":
and beforecase "textarea":
.