I’m noticing that the TbGroupGridView’s headers are using the ID of he row below it. This happens on the row AFTER a group header. So when I click on a row with data the $.fn.yiiGridView.getSelection(id) is returning the ID of the wrong row.
Has anyone else run into this before?
Here’s my code:
$this->widget('bootstrap.widgets.TbGroupGridView', array(
'type'=>'striped bordered',
'dataProvider'=>$invoiceProvider,
'showTableOnEmpty'=>true,
'template'=>"{items}",
'id'=>'invoice-grid',
'selectionChanged'=>
'function(id){
var invoice_id = parseInt($.fn.yiiGridView.getSelection(id)); // The ID is is always the one AFTER the row selected because of the Group Headers!
window.location="school/updateinvoice/"+invoice_id;
}',
'extraRowColumns'=> array('group_id'),
'extraRowExpression' => 'format_grouping($data)',
'extraRowHtmlOptions' => array('style'=>'padding:10px'),
'columns'=>array(
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
'template'=>'{delete}',
'buttons'=>array(
'delete'=>array(
'url'=>'$this->grid->controller->createUrl("//school/deleteinvoice", array("invoice_id"=>$data["invoice_id"]))',
)
),
),
array(
'name'=>'school_class',
'header'=>"School/Class Name",
'type'=>'html',
),
array(
'name'=>'students',
'header'=>'Students',
'type'=>'html',
'htmlOptions'=>array('style'=>'text-align:right;'),
),
array(
'name'=>'total_fee',
'header'=>'Total Fee',
'type'=>'html',
'htmlOptions'=>array('style'=>'text-align:right;','width'=>'85px'),
),
array(
'name'=>'start',
'header'=>'Start',
'type'=>'html',
'htmlOptions'=>array('style'=>'text-align:right;'),
),
array(
'name'=>'end',
'header'=>'End',
'type'=>'html',
'htmlOptions'=>array('style'=>'text-align:right;'),
),
array(
'name'=>'total_due',
'header'=>'Total Due',
'type'=>'html',
'htmlOptions'=>array('style'=>'text-align:right;'),
),
array(
'name'=>'invoiced',
'header'=>'Invoiced',
'type'=>'html',
'htmlOptions'=>array('style'=>'text-align:right;'),
// 'value'=>'format_total_invoiced($data)'
),
array(
'name'=>'paid',
'header'=>'Amount(s) Paid',
'type'=>'html',
'htmlOptions'=>array('style'=>'text-align:right;'),
// 'value'=>'format_amounts_paid($data)'
),
array(
'name'=>'owed',
'header'=>'Still Owed',
'type'=>'html',
'htmlOptions'=>array('style'=>'text-align:right;'),
// 'value'=>'format_owed($data)'
),
array(
'name'=>'notes',
'header'=>'Notes',
'type'=>'html',
),
array(
'name' => 'group_id',
'headerHtmlOptions' => array('style'=>'display:none'),
'htmlOptions' =>array('style'=>'display:none')
),
)
));
Thanks.