-
-
Notifications
You must be signed in to change notification settings - Fork 13
Description
get key by javascript ie : $.fn.yiiGridView.getSelection(id)
If you want to react when selection change you have a line like that in your grid :
'selectionChanged'=>"function(id){window.location='" . Yii::app()->urlManager->createUrl('controller/action', array('id'=>'')) . "' + $.fn.yiiGridView.getSelection(id);}",
But this didn't work well because of extra rows added by the extraRowColumns property of the grid. In order to make it work you have to override the renderKeys method from CBaseListView. Just add the code below into the GroupGridView class file.
/**
* override CBaseListView->renderKeys to add an extra tag
* so the keys take in account extra row from GroupGridView
*/
public function renderKeys()
{
echo CHtml::openTag('div',array(
'class'=>'keys',
'style'=>'display:none',
'title'=>Yii::app()->getRequest()->getUrl(),
));
$keys = $this->dataProvider->getKeys() ;
$n=count($keys);
for($row=0;$row<$n;++$row) {
$extraRowEdge = null;
if(count($this->extraRowColumns)) {
$colName = $this->extraRowColumns[0];
$extraRowEdge = $this->isGroupEdge($colName, $row);
if($this->extraRowPos == 'above' && isset($extraRowEdge['start'])) {
echo "<span></span>";
}
}
echo "<span>".CHtml::encode($keys[$row])."</span>";
if(count($this->extraRowColumns) && $this->extraRowPos == 'below' && isset($extraRowEdge['end'])) {
echo "<span></span>";
}
}
echo "</div>\n";
}
Hope it help.