Note that there are some explanatory texts on larger screens.

plurals
  1. POJQGrid: 'beforeSelectRow' and 'sortableRows' - exclude column from being draggable?
    primarykey
    data
    text
    <p>I am using <a href="https://stackoverflow.com/users/315935/oleg">Oleg</a>'s <a href="https://stackoverflow.com/questions/5303471/browser-memory-usage-comparison-inline-onclick-vs-using-jquery-bind">suggestion</a> to use the <code>beforeSelectRow</code> event to handle clicks on cells within my grid. </p> <p>Oleg's code in his answer (which mine exactly mimics):</p> <blockquote> <p>You can define the columns with buttons like following</p> </blockquote> <pre><code>{ name: 'add', width: 18, sortable: false, search: false, formatter:function(){ return "&lt;span class='ui-icon ui-icon-plus'&gt;&lt;/span&gt;" }} </code></pre> <blockquote> <p>In the code above I do use custom formatter of jqGrid, but without any event binding. The code of</p> </blockquote> <pre><code>beforeSelectRow: function (rowid, e) { var iCol = $.jgrid.getCellIndex(e.target); if (iCol &gt;= firstButtonColumnIndex) { alert("rowid="+rowid+"\nButton name: "+buttonNames[iCol]); } // prevent row selection if one click on the button return (iCol &gt;= firstButtonColumnIndex)? false: true; } </code></pre> <blockquote> <p>where <code>firstButtonColumnIndex = 8</code> and <code>buttonNames = {8:'Add',9:'Edit',10:'Remove',11:'Details'}</code>. In your code you can replace the alert to the corresponding function call.</p> </blockquote> <p>The problem is that my grid is also sortable- (I use the <code>sortableRows</code> method on my grid). If the user is moving the mouse even a little when clicking the cell, the <code>beforeSelectRow</code> event is never triggered (the sortable event is). </p> <p>This is desirable in most situations- however, I think what would fix this is to somehow exclude columns from being 'handles' to drag (sort) the row and let my <code>onSelectRow</code> event trigger on those columns. I just can't seem to figure out how to do this! Any help is extremely appreciated :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload