Csqldataprovider And Cbuttoncolumn

I’m using CSqlDataProvider to provide data for CGridView. It all runs fine until I want to add CButtonColumn column. It resultsl in error:


Trying to get property of non-object

and in the stack there


echo $this->displayExtendedSummary && !empty($this->extendedSummary['columns']) 

            ? $this->parseColumnValue($column, $row) : $column->renderDataCell($row);

at file:


c:\...\yii\framework\zii\widgets\grid\CButtonColumn.php(316)

Any ideas how to deal with that?

EDIT:

Provider:


$provider = new CSqlDataProvider($query, array(

			'totalItemCount' => $countRes,

			'db' => $this->db,

			'keyField' => 'idCall',

			'params' => $params,

			'pagination' => array(

				'pageSize' => 25,

			),

			'sort' => array(

				'attributes' => array(

					'idCall, idTime',

				),

			),

		));



In view:


<?php $this->widget('bootstrap.widgets.TbExtendedGridView', array(

	'id'=>'call-history-grid',

	'type' => 'striped condensed',

	'template' => '{pager}{items}{summary}',

	'htmlOptions' => array('style' => 'font-size: 0.75em'),

	'dataProvider'=>$model->getInviteCallList(),

	'columns'=>array(

		array(

			'header' => '#',

			'value' => '$data["idCall"]',

			'visible' => 'Yii::app()->user->superuser',

		),

		array(

			'header' => 'Data',

			'value' => '$data["callDateTime"]',

		),

                		array(

			'class'=>'zii.widgets.grid.CButtonColumn',

		),

I use here bootstrap gridview but if I switch to regular CGridView - problem is the same.

I noticed, the problem is in the CComponent.php file:


public function evaluateExpression($_expression_,$_data_=array(), $die=false)

	{

		if(is_string($_expression_))

		{

			extract($_data_);

			// to code cannot to do the eval function

			return eval('return '.$_expression_.';');

		}

		else

		{

			$_data_[]=$this;

			return call_user_func_array($_expression_, $_data_);

		}

	}

I see the problem. The expression contains that piece of code:


$data->primaryKey 

When you use eg. CActiveDataProvider - there is a key called primaryKey after doing the extract($data) but when you use CSqlDataProvider - the key/val pair does not exist. I’m not sure yet how to solve it.

I’ve got the answer. Link: http://stackoverflow.com/a/16060720/725116