Forum

July 10th, 2011
You must be logged in to post Login Register

Search Forums:


 






what is the form id

No Tags
UserPost

06:48
06/09/2010


stephen

Member

posts 9

As we know, formid is the parameter of some functions, for example, beforeSubmit.

But I found it is not a string, alert(formid), it is "[object] [object]".

What's the actual value of form id? Thanks.


13:17
06/09/2010


OlegK

Germany

Member

posts 1210

Post edited 13:21 – 06/09/2010 by OlegK


It is just a small bug in the documentation. formid is not a string like if described in the documentation. It is just jQuery object for the form. The corresponding line looks like

if( $.isFunction(rp_ge.beforeSubmit))  { ret = rp_ge.beforeSubmit(postdata,$("#"+frmgr)); }

In the same form fill be called all callback function like onInitializeForm, beforeCheckValues afterComplete, beforeShowForm, afterShowForm, beforeInitData and so on.

Somebody should just change the documentation of the wiki page http://www.trirand.com/jqgridw…..rm_editing. (Everyone can do it)

Regards
Oleg 

08:29
07/09/2010


stephen

Member

posts 9

Thanks, Oleg

Yes, I found the "frmgr = "FrmGrid_"+gID,frmtb = "TblGrid_"+gID"  on line 236 in grid.formedit.js,
the variable "frmgr" will be passed as jQuery object ($("#frmgr")) to many functions like "beforeShowForm".
I have a question. If there are more than one grids in one page and they use the same "beforeShowForm" function, how to know the call come from gridA or gridB?
I want to distinguish them with the id or name of the form/grid, but I can't get the id or name from the parameter formid, alert(formid.id) is "undefined".
Is there any good way to get the id or name of form/gird in this function?

12:02
07/09/2010


OlegK

Germany

Member

posts 1210

Hi stephen!

You make very simple error. jQuery objects are a wrapper over array of DOM objects and the DOM object itself. If you use

var x = $("#blabal");

then x will be a wrapper to the arrays of DOM objects found by selector #blabal. It x.length === 0 then no elements are found. If do some elements are found, then you can access the elements with x[i].

So to display the id of the form identified by the jQuery object form you should use not the syntax alert(form.id) but alert(form[0].id):

beforeSubmit : function(postdata, form) {

    alert ("in beforeSubmit formid=" + form[0].id);

}

Best regards
Oleg

05:07
08/09/2010


stephen

Member

posts 9

Hi Oleg!

Appreciate your reply, you are right I made a mistake at this point. 

The id of form is "FrmGrid_"+gridId and the name is "FormPost"(they are defined in grid.formedit.js), we can know different grid/form by the id, but I don't know why doesn't the form name have a prefix like form id? Perhaps it doesn't matter.

Anyway, thanks for your warm heart.

Thanks,

Stephen

05:26
08/09/2010


stephen

Member

posts 9

Post edited 05:44 – 08/09/2010 by stephen


OlegK said:

It is just a small bug in the documentation. formid is not a string like if described in the documentation. It is just jQuery object for the form. The corresponding line looks like

Somebody should just change the documentation of the wiki page http://www.trirand.com/jqgridw…..rm_editing. (Everyone can do it)

Regards
Oleg 


Hi Oleg, I have changed this documentation.

I have replaced "the id of the form" by "the jQuery object of form id, you can use formid[0].id to get form id".

Please let me know if it is acceptable or not.

Additionally, I didn't change the description of formId in the event beforeCheckValues since it is ok.

Please let me know if anything is missing.

Thanks,
Stephen


11:57
08/09/2010


OlegK

Germany

Member

posts 1210

It's OK Stephen. The most important that the documentation has correct and not wrong information. Some releases before formid parameter was really form id, now it is jQuery form object. I personally would be better to rename the parameter from formid to form in the documentation.

Best regards
Oleg 

No Tags

About the jQuery Grid Plugin – jqGrid forum

Most Users Ever Online:

215


Currently Online:

41 Guests

Forum Stats:

Groups: 1

Forums: 7

Topics: 10274

Posts: 30361

Membership:

There are 11038 Members

There have been 448 Guests

There is 1 Admin

There are 2 Moderators

Top Posters:

OlegK – 1210

markw65 – 179

kobruleht – 144

phicarre – 132

YamilBracho – 124

Renso – 118

Administrators: admin (60 Posts)

Moderators: tony (7383 Posts), Rumen[Trirand] (81 Posts)




Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information