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
calling callback after jQuery event, which return a value
08/11/2014
13:41
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hello Tony,

I think that the logic in calling of callbacks like beforeSelectRow after the corresponding event (jqGridBeforeSelectRow in case of callback beforeSelectRow) is not full correct now. Let us I explain all on an example.

If one register multiple jqGridBeforeSelectRow events and one beforeSelectRow callback in one grid then one could need two possible reasons:

  • one want to deny selection of rows in some specific situations
  • one need to handle onClick event somewhere inside of grid. For example one could place <span class="ui-icon ui-icon-flag"></span> in a column and to do some action if the user clicks on the flag icon.

The current implementation of jqGrid calls all jQuery events (all handlers of the event jqGridBeforeSelectRow), but it don't calls beforeSelectRow callback if the last event handler returns false or "stop" string. So the implementation of onClick logic described before will be failed. If will also skip calling of any jqGridCellSelect events, onCellSelect callback and editCell (in case of usage cellEdit:true). Such behavior seems a bug for me.

The correct behavior seems to me the following: one should call all jqGridBeforeSelectRow, jqGridCellSelect events and beforeSelectRow, onCellSelect callbacks and call editCell if required (cellEdit:true is set click and the click was not on multiselect checkbox), but one need don't make selection of the row if either jqGridBeforeSelectRow or beforeSelectRow return false or "stop".

I could post my suggestion as pull request, but because my previous pull request is still pending I can't do this. So I describe shortly my suggestion below:

The line

if(cSel && $.isFunction(ts.p.beforeSelectRow)) { cSel = ts.p.beforeSelectRow.call(ts,ptr[0].id, e); }

should be replaced to the following

if ($.isFunction(ts.p.beforeSelectRow)) {
    var allowRowSelect = ts.p.beforeSelectRow.call(ts,ptr[0].id, e);
    if (allowRowSelect === false || allowRowSelect === 'stop') {
        cSel = false;
    }
}

The line 

if(cSel === true) {

together with the closing '}' (see here) need be removed.

The line

if(ts.p.multiselect && scb){

should be modified to

if(ts.p.multiselect && scb && cSel){

The line 

} else if ( !ts.p.multikey ) {

should be replaced to

if (!cSel) {
    return;
}
if ( !ts.p.multikey ) {

It seems be all. One need of course to adjust indentation of the lines which was before inside of if(cSel === true) {...}.

One have some other events which could returns values (jqGridRowAttr, jqGridBeforeRequest, jqGridSortCol and so on). One can make the corresponding changes in the code of jqGrid for the events later.

Best regards
Oleg

P.S. An example of suggested above modification of jquery.jqGrid.src.js one can find here.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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