ana.maiden
(Ana Maiden)
1
I just want to store the ids of the ticket items, when I check the console I’m just getting an empty array. any idea why?
Yii doc on CCheckBoxColumn states:
font: http://www.yiiframework.com/doc/api/1.1/CCheckBoxColumn#selectableRows-detail
So I have:
$this->widget('bootstrap.widgets.BsGridView', array(
'id' => 'audits-lines-grid',
'dataProvider' => $auditlines->search($model->audit_id),
'filter' => $auditlines,
'selectableRows' => 2,
'columns' => array(
array(
'class' => 'CCheckBoxColumn', 'selectableRows' => 2,
'id' => 'selected-checkboxes',
'value' => 'CHtml::tag("span", array("class" => "$data->statusLabel"), "$data->status", "</span>")',
'name' => 'CHtml::tag("span", array("class" => "$data->statusLabel"), "$data->status", "</span>")',
),
(some more code here..)
and I’m trying to get the checked value with
<script>
$(document).on('click','#block-change-location',function(){
var items = $('#audits-lines-grid').yiiGridView('getChecked', '#selected-checkboxes')
console.log(items);
});
</script>
Yet the console is returning an empty array, any idea why?
Thanks
oligalma
(Marc Oliveras)
2
I don’t know if this will solve your problem, but there is a semicolon missing at the end of the following line:
var items = $('#audits-lines-grid').yiiGridView('getChecked', '#selected-checkboxes')
mdomba
(Maurizio Domba Cerin)
3
Hi ana and welcome to the forum
The second parameter should be just the columnID without the ‘#’ so the call should be
var items = $('#audits-lines-grid').yiiGridView('getChecked', 'selected-checkboxes')
ana.maiden
(Ana Maiden)
4
You’re right, semicolon was missing but that didn’t solve. I found out a similar code that does work, its:
var id = $.fn.yiiGridView.getChecked("your-grid-id", "selected-checkboxes");
important: when entering the id, don’t add a # (eg. ‘id-name’ is correct, ‘#id-name’ is wrong), hope it helps somebody else
ana.maiden
(Ana Maiden)
5
Thanks Maurizio, that worked too 