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:
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:
1 |
if(cSel && $.isFunction(ts.p.beforeSelectRow)) { cSel = ts.p.beforeSelectRow.call(ts,ptr[0].id, e); } |
should be replaced to the following
1 2 3 4 5 6 |
if ($.isFunction(ts.p.beforeSelectRow)) {<br /> var allowRowSelect = ts.p.beforeSelectRow.call(ts,ptr[0].id, e);<br /> if (allowRowSelect === false || allowRowSelect === 'stop') {<br /> cSel = false;<br /> }<br /> } |
1 |
<span class="k">if</span>(cSel <span class="o">===</span> <span class="kc">true</span>) { |
together with the closing ‘}’ (see here) need be removed.
1 |
<span class="k">if</span>(ts.p.multiselect <span class="o">&&</span> scb){ |
should be modified to
1 |
if(ts.p.multiselect && scb && cSel){ |
1 |
} <span class="k">else</span> <span class="k">if</span> ( <span class="o">!</span>ts.p.multikey ) { |
should be replaced to
1 2 3 4 |
if (!cSel) {<br /> return;<br /> }<br /> 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.
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top