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
Implement grid event and call default event behavior?
08/10/2009
17:34
Avatar
dvorak
Member
Members
Forum Posts: 4
Member Since:
09/10/2009
sp_UserOfflineSmall Offline

There are many very useful extension points in the grid however I often find that I'd like the default behavior for an event to still take place, along with a bit of my code. So have it run the code in my function and then do what it normally would have done have I not provided this function.

For example, say I implement beforeSelectRow event:

beforeSelectRow: function(rowid) {

                jQuery("#my_div").css({ "white-space" : "normal", "height" : "30px" });
},

Is there a way to then call the default beforeSelectRow() event handler in jqGrid? Something like base.beforeSelectRowI(rowid)?

I know this isn't exactly object oriented programming so, I'm wondering if there's a way to emulate this behavior. use jquery's trigger event functionality?

09/10/2009
04:24
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

For what I understand you can:

beforeSelectRow: function(rowid, e)

{

myfunction();

}

Outside the grid

function myfunction ()

{

// do something

}

And then you can call it where you want

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

09/10/2009
12:06
Avatar
dvorak
Member
Members
Forum Posts: 4
Member Since:
09/10/2009
sp_UserOfflineSmall Offline

Thanks for the reply Tony. Sorry, I don't think I explained my problem right. So jqgrid has default event behavior for when the user selects a row for example. If I implement an event, like beforeSelectRow, then the default behavior does not happen. Only what's in my beforeSelectRow function will be run. I'm trying to find a way to have it do both. Execute jqgrid's default event behavior as well as my code.

beforeSelectRow: function(rowid) {

    // do some custom code

    // do jqgrid's default beforeSelectRow code

};

09/10/2009
14:57
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

Unfortunately, the exact way to do this varies depending on the callback, but for the beforeSelectRow, just return "true".

Mark

09/10/2009
18:06
Avatar
dvorak
Member
Members
Forum Posts: 4
Member Since:
09/10/2009
sp_UserOfflineSmall Offline

Gotcha. That worked. Thanks Mark!

16/11/2009
04:00
Avatar
Sloub
France
Member
Members
Forum Posts: 4
Member Since:
13/11/2009
sp_UserOfflineSmall Offline

Hello,

Is there something special to do for the "return true" to work ?

I had that first problem : http://www.trirand.com/blog/?p.....ut-fields/

Thank's to Mark, this is solved, except that in my case, the return true does not seem to execute default behaviour.

beforeSelectRow: function(rowId, e) {
            myBeforeSelectRow(rowId,e);
}

//outside the grid : this should act as default handler

function myBeforeSelectRow(rowid, e) {
        return true;
}

This code does not work for me, either on ie 6, nor firefox 3.x  & jqgrid 3.6

Thank's for your help

Sloub

16/11/2009
04:10
Avatar
dvorak
Member
Members
Forum Posts: 4
Member Since:
09/10/2009
sp_UserOfflineSmall Offline

This worked in my case in IE7/FF, etc.

Are you missing the return keyword in the beforeSelectRow() function?

beforeSelectRow: function(rowId, e) {
            return myBeforeSelectRow(rowId,e);
}

16/11/2009
05:24
Avatar
Sloub
France
Member
Members
Forum Posts: 4
Member Since:
13/11/2009
sp_UserOfflineSmall Offline

thank's dvorak, this works better with the return statement.

Sloub

16/11/2009
08:28
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

Or, simpler and more efficient:

beforeSelectRow: myBeforeSelectRow

(ie there's no need to wrap your handler in an anonymous function)

Mark

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
72 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