Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





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

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Dynamically binding events to jqGrid
27/10/2010
18:23
Avatar
Mike54
Poland
Member
Members
Forum Posts: 4
Member Since:
19/10/2010
sp_UserOfflineSmall Offline

Hello,

I have the following problem.

When I create a Grid – and as a part of configuration provide handler function for – lets say: onSelectRow, like this:

$("#list").jqGrid({
    colNames:['Inv No','Date', 'Client'],
    colModel:[...],
    onSelectRow: function(rowid, status){ alert(rowid); }
});

It works like a charm and pops up alert dialog with selected row ID.

In my project I'm importing grid configuration using 'jqGridImport' and I would like to add / bind event handler after the grid is complete, so probably on importComplete event.

The problem is that if I'm trying to add handlers later on, they do not work:

 Type 1:

$("#list").jqGrid({
 onSelectRow: function(rowid, status){alert(rowid);}
 });

Type 2:

 ("#list").bind("jqGridonSelectRow", function(){ alert("a"); });

Both examples do not work. Can you please tell me how should this be done correctly?

I will really appreciate any help, thank you!

27/10/2010
21:07
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hello

If you want to set any event function dynamically with

$('#list').jqGrid('setGridParam', { onSelectRow: function(id){ alert(id); } } );

Best regards

Oleg 

28/10/2010
00:24
Avatar
Mike54
Poland
Member
Members
Forum Posts: 4
Member Since:
19/10/2010
sp_UserOfflineSmall Offline

Big thanks Oleg!

I don't know how I could have missed that!

If you ever come to Warsaw I owe you a beer 🙂

Best regards,

Mike

30/10/2010
01:03
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

You welcome Mike!

Warsaw is a little far from Bonn, so I am not sure that we can sometime realize the idea with a bear. Nevertheless I find the idea very good! Thanks.

Best regards
Oleg 

12/11/2010
23:05
Avatar
andregio
New Member
Members
Forum Posts: 2
Member Since:
12/11/2010
sp_UserOfflineSmall Offline

I'm using the MVC version of the grid, and I cannot find how the event "beforeSubmit" for edit form should be bound at the Controller.

Is it possible to use setgridparam to bind the event "beforeSubmit" of the edit form? or is there a way to set it in the Controller?

Thanks in advance.

Andrea.

13/11/2010
01:42
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hello Andrea,

The event beforeSubmit is not a general jqGrid event so you can't use setGridParam to set it dynamically. I don't know which way for it exist in the commercial jqGrid version (probably you can ask a question of the trirand.net forum). Nevertheless one way will be work independent from the implementation. You can use 

jQuery.extend(jQuery.jgrid.edit, {
    beforeSubmit : function(postdata, formid) {
        /*your implementation*/
    }
});

to define beforeSubmit or any other event of editGridRow function of form editing.

Best regard
Oleg 

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
76 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information