* @var string a PHP expression that is evaluated for every update button and whose result is used
* as the URL for the update button. In this expression, the variable
* <code>$row</code> the row number (zero-based); <code>$data</code> the data model for the row;
* and <code>$this</code> the column object.
*/
public $updateButtonUrl='Yii::app()->controller->createUrl("update",array("id"=>$data->primaryKey))';
So, you need to configure it manually.
There is however another solution!
I was wondering why I never have met this problem. The reason is that I use User-friendly URLs . So that is a way to make the buttons create a valid url even if you changed the name of primaryKey. But I think the User Friendly Urls are good to use for other reasons as well, and quite easy to implement. See the link.
Great thank you for finding were id= is created, i am very tempted to change it, but i wont because i know when i update the framework, i will forget that i changed that! lol
Also, thanks for the tip on friendly URLS, I guess that will fix the problem for sure. I do prefer friendly URLS (Hate ?id=xyz …) I tried creating them early in the project, but reverted back becasue all urls still had index.php? which is really weird. I think I tried out something with htaccess rewrites, but gave up.
Hi i m trying to do the same but a got the error notice "Trying to get property of non-object" even when i m takin off all the attributes of CButtonColumn.
If i take off the CButtonColumn array of the CGridView this is shown well (without the options of course).
the dataProvider is created with a CSqlDataProvider with a custimized quuery with a join with 2 tables, its possibly that result dont match with any model in the system and,this could be the error but, this can be fixed?
code the model
public static function myData($id = '' )
{
$count=Yii::app()->db->createCommand('SELECT COUNT(xx)
FROM rr AS cs
INNER JOIN zz AS c ON c.id = cs.rr_id
WHERE cs.hh_id =\''.$id.'\'')->queryScalar();
$sql='SELECT cs.id, aa, bb, cc
FROM rr AS cs
INNER JOIN zz AS c ON c.id = cs.rr_id
WHERE cs.hh_id =\''.$id.'\'';
$dataProvider=new CSqlDataProvider($sql, array(
'totalItemCount'=>$count,
'sort'=>array(
'attributes'=>array(
'id', 'aa', 'bb','cc',
),
),
'pagination'=>array(
'pageSize'=>30,
),
));
return $dataProvider;
// $dataProvider->getData() will return a list of arrays.
}