javascript - Callback for Yii2's GridView CheckboxColumn -
i have gridview
(yii2) , 1 of columns boolean type of data. want able toggle value , have saved in database.
i need callback that, don't see checkboxcolumn
having one. how can achieve this?
don't go looking far. use checkboxoptions
-property of column setup add specific class
checkboxes. can use jquery event listen changes , report them back:
$('.checkbox-column').change(function(e) { var checked = $(this).is(':checked'); $.ajax('route/target', {data: {id: $(this).closest('tr').data('key'), checked: checked}}); });
yii's gridview
renders data-key
-attribute every row (on <tr>
) can use identify actual record update.
as alternative: $('input:checkbox', $('#w0')).change()
work, assuming don't want class , gridview
first widget.
Comments
Post a Comment