Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jeamartin opened this issue Aug 18, 2014 · 0 comments
Open

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

jeamartin opened this issue Aug 18, 2014 · 0 comments

Comments

@jeamartin
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant