CGridVew right click

Hi Yii,

So I know that CGridView has a “SelectionChanged” attribute that can return the clicked row, but this doesn’t seem to listen for a right click action.

Is there any way to do this without having to create a new JS function? And if so, how do I call the new JS function on the rows?

Thank you

You are definitely going to have to listen to click events with JavaScript, and filter out only clicks with the right mouse button. CGridView can’t do what you want out of the box.

Here is a post explaining how to make the whole row clickable with JS:

It should get you pointed in the right direction.

So I have tried this and it gets the right primary key when i put the event.keyCode == 0. But when I changed it to event.keyCode == 2 for the right click it just brings up the regular context menu.

Here is my widget being called in the view:

$this->widget('zii.widgets.grid.CGridView', array(






Here is the javascript:

<script type="text/javascript">

function userClicks(target_id) {

    if(event.keyCode == 0)