CheckboxColumn get checked with jQuery

Hi guys,

I have a small situation here. I have a grid view with checkboxes. Now I want to have checkbox column so that when I select 1 checkbox in the checkbox column, all checkboxes in the row will be checked. Atleast that is what I want.

However, I can not seem to get a trigger on a checkbox with jQuery to see if a checkbox is checked or not. How can I accomplish this?

Best regards.

Have you tried with:

$('#mainCheckbox').click(function () {

    $(".otherCheckboxes").prop('checked', $(this).prop('checked'));


I wish I could try that. I can not even seem to figure out how to give a checkbox column my own id.

in CHtml::checkbox add third parameter with array(‘id’ => ‘#mainCheckbox’)

Can not get it to work with the checkboxColumn. Tried it, but did not apply the id.

There is an id attribute:

The link is for Yii 1. I use Yii 2 and in the documentation it doesn’t say anything about an id property.

Default checkbox’s id is same of name.

To be sure, check with firebug id of checkbox.

Problem is that the checkbox is not really a checkbox as a normal input. It’s been altered because of Twitter bootstrap I think.

I think i found some info that I can use. I read over it in the documentation. According to the documentation with this JS line I should be able to get the selected checkboxes:

var keys = $(’#grid’).yiiGridView(‘getSelectedRows’);

Going to give that a try later today.

Also input’s html has id field.