How to add onclick event on certain columns only with Yii2 Gridview rowOptions
<p>I have a gridview and enabled only Delete button in ActionColumn. There is no problem when I try to click the <code>ok</code> from the confirm box when the delete button is pressed. The problem is when <code>cancel</code> button is pressed in confirmation. What happens is, it redirects the page depending on the url returned by rowOptions.</p>

<pre><code>             [
              'class' =&gt; 'yii\grid\ActionColumn',
                    'template' =&gt; '{delete}',
             ],
        ],
            'rowOptions' =&gt; function($model, $index, $attribute) {
                    $url = "whatever url"

                    if ($index &gt; 0) {
                        return [
                            'onclick' =&gt; "window.location.href='{$url}'",
                            'style' =&gt; 'cursor:pointer'
                        ];
                    }
            }
</code></pre>