Forum

May 22nd, 2014
A A A

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

    

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
what is the form id
06/09/2010
06:48
stephen
Member
Forum Posts: 9
Member Since:
06/09/2010
Offline

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.

06/09/2010
13:17
OlegK
Germany
Member
Forum Posts: 1233
Member Since:
10/08/2009
Offline

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 /jqgridwiki/doku.php?id=wiki:form_editing. (Everyone can do it)

Regards
Oleg 

07/09/2010
08:29
stephen
Member
Forum Posts: 9
Member Since:
06/09/2010
Offline

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?

07/09/2010
12:02
OlegK
Germany
Member
Forum Posts: 1233
Member Since:
10/08/2009
Offline

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

08/09/2010
05:07
stephen
Member
Forum Posts: 9
Member Since:
06/09/2010
Offline

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

08/09/2010
05:26
stephen
Member
Forum Posts: 9
Member Since:
06/09/2010
Offline

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 /jqgridwiki/doku.php?id=wiki:form_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

 

08/09/2010
11:57
OlegK
Germany
Member
Forum Posts: 1233
Member Since:
10/08/2009
Offline

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 

Forum Timezone: Europe/Sofia

Most Users Ever Online: 215

Currently Online:
52 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1233

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11315

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10523

Posts: 31109

Newest Members: jqGridForStruts, shrat, wheeliea, dontbannedme, duyquang, jhardt1

Moderators: tony: 7679, Rumen[Trirand]: 81

Administrators: admin: 61

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information