bool.dev
(Lightcycleuser)
March 20, 2012, 4:25pm
1
I’m trying to set the header cell text for a CCheckBoxColumn but it’s not working, does anyone know what’s wrong?
Code:
'columns'=>array(
'name',
'expiry_date',
array(
'class'=>'CCheckBoxColumn',
'id'=>'check_boxes',
'header'=>'Selected',
'footer'=>'Checked',
),
),
'selectableRows'=>2
The footer text is shown correctly.
bool.dev
(Lightcycleuser)
March 20, 2012, 9:09pm
2
I checked the generated html, which didn’t have any field for the header of the checkboxcolumn.
The generated html:
<table class="items">
<thead>
<tr>
<th id="example-grid_c0"><a href="/sampleapp/index.php/something/index/sort/name">Name</a></th>
<th id="example-grid_c1"><a href="/sampleapp/index.php/something/index/sort/expiry_date">Expiry</a></th>
<th class="checkbox-column" id="check_boxes"><input class="select-on-check-all" type="checkbox" value="1" name="check_boxes_all" id="check_boxes_all" /></th>
<th class="button-column" id="job-grid_c11"> </th></tr>
<tr class="filters">
...
abennouna
(Abennouna)
March 20, 2012, 10:19pm
3
Well according to the documentation, the fact you put [font=“Courier New”]‘selectableRows’=>2[/font] will put a checkbox in the header that allows to select/deselect the entire column.
bool.dev
(Lightcycleuser)
March 21, 2012, 3:25am
4
Of course, i have seen the documentation, but then what if i also want some text next to the checkbox in the header?
Further if we check the source of the renderHeaderCellContent, we see that it renders header text only if selectableRows<=1, otherwise it renders the checkbox and no header text. I feel this fact should be documented. I’ll go put a comment in the docs now. Thanks for your reply though.
mdomba
(Maurizio Domba Cerin)
March 21, 2012, 9:02am
5
There is an issue currently worked on about this - https://github.com/yiisoft/yii/pull/391
bool.dev
(Lightcycleuser)
March 21, 2012, 3:01pm
6
Thank you for the link @mdomba
Jay_69
(Biz)
August 1, 2012, 11:10am
7
Hi
I have a CGridView with seven CCheckBoxColumn for each day of the week with ‘selectableRows’=>2
CGridColumn does not have filter so I have used that space for naming the columns and it looked pretty.
Used the following JS:
Yii::app()->clientScript->registerScript('setColNames', "
$('#grid_id .filters').attr('align','center');
$('#grid_id .filters').children(':nth-child(1)').text('Su');
$('#grid_id .filters').children(':nth-child(2)').text('Mo');
$('#grid_id .filters').children(':nth-child(3)').text('Tu');
$('#grid_id .filters').children(':nth-child(4)').text('We');
$('#grid_id .filters').children(':nth-child(5)').text('Th');
$('#grid_id .filters').children(':nth-child(6)').text('Fr');
$('#grid_id .filters').children(':nth-child(7)').text('Sa');
");
Where #grid_id - is the id of the CGridView and :nth-child(n) - is the order of the cell.
Put this code at the end of the view.
Cheers.