I have a GridView
(Yii2) and one of the columns is a boolean type of data. I want to be able to toggle that value and have it saved in my database.
I need a callback for that, but I don't see CheckboxColumn
having one. How can I achieve this?
I have a GridView
(Yii2) and one of the columns is a boolean type of data. I want to be able to toggle that value and have it saved in my database.
I need a callback for that, but I don't see CheckboxColumn
having one. How can I achieve this?
Don't go looking too far. Just use the
checkboxOptions
-property of your column setup to add a specificclass
to all checkboxes. Then you can use a jQuery event to listen to changes and report them back:Yii's
GridView
normally renders adata-key
-attribute for every row (on the<tr>
) that you can use to identify the actual record to update.As an alternative:
$('input:checkbox', $('#w0')).change()
could also work, assuming you don't want the extra class and that theGridView
is your first widget.