0

in my jqgrid i have field in a table which represents the id and i have set it as follows

{name:'e_info_id',index:'e_info_id', width:60, sorttype:"int",key: true}

and for json reader i have set it as

 jsonReader : { repeatitems: false ,id: "e_info_id",root:"rows"}

Now when i click on the Add/Edit icon , an Edit dialog opens up , as i haven't set e_info_id as editable:true that id field won't shown into the form dialog box, but when i click on submit i am not be able to access that id in a following function

 onclickSubmit: function (options, postdata) {

          postdata.e_info_id // is undefined 

 }

but as soon as i define e_info_id as editable=true , postdata.e_info_id has a value now. Now i see this a quite strange and i dont know how to get rid off this

{name:'e_info_id',index:'e_info_id', width:60, sorttype:"int",key: true,editable:true}

Moreover , to keep user from accidently update the e_info_id i tried to hide it as follow and keep the editable:true just to get the value of e_info_id in $.jgrid.edit.

   beforeShowForm: function(form) { $('#tr_e_info_id', form).hide(); }

But the issue with this , when i double click the row of a table beforeShowForm doesnt get fire so the e_info_id field appears.

ondblClickRow: function(rowid) {
        $(this).jqGrid('editGridRow',rowid);
    }

now i am out of workarounds , so basically my problem is not to show the e_info_id field in a add/edit dialog box and yet get the value of e_info_id in onclickSubmit

Hunt
  • 8,215
  • 28
  • 116
  • 256

1 Answers1

1

Why you use both key: true and jsonReader : { id: "e_info_id",...}? I think it's you main problem. I recommend you remove id: "e_info_id" and use key: true only.

Moreover I didn't understand the meaning of the 'e_info_id' column. If you fill jqGrid with the correct id attributes in the rows (id of <tr>) then the id will be sent to the server under the name 'id' (if you remove id: "e_info_id" from jsonReader). Do you want to show the column for the user at all? Do you want that the user see the information in "Edit" form? All options is possible, but it's not depend

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • i wanna show the id in a table but now in a form dialog , i have removed id="e_info_id" from jsonReader now i have jsonReader : { repeatitems: false } only and key:true set in a colModel , but still postdata.id undefined – Hunt Mar 29 '12 at 20:29
  • if i remove the whole line jsonReader : { repeatitems: false } then i get Uncaught TypeError: Cannot read property '0' of undefined and nothing gets load – Hunt Mar 29 '12 at 20:31
  • You should remove **only** `id: "e_info_id"` part from the `jsonReader`. About the name of the property **inside** of `onclickSubmit` I wrote you before (see [here](http://stackoverflow.com/questions/9926586/not-able-to-get-the-actual-record-id#comment12671288_9926586)) that the name will be constructed from the id of the grid + '_id' text. Then the prefix with gridId will be cut and so modified `postdata` will be sent to the server. I recommend you just set breakpoint inside of `onclickSubmit` and you will see all. – Oleg Mar 29 '12 at 20:40