Skip to content

I know i should do a fork, but i propose this #6

@jeamartin

Description

@jeamartin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions