adding extra button on cgridview


I would l like to add an extra button on the cgridview and link to one javascript function

'buttons'=>array('up'=>array('label'=>'up', 'url'=>'javascript:moveUp()', 'imageUrl'=>'/css/admin/gridview/up.png')),

but it gives me error like

Parse error: syntax error, unexpected ‘:’ in

any idea to fix this problem



This is because buttons url must be an PHP expression, to call a javascript function, you have to do like,

'buttonID' => array


    'label'=>'...',     //Text label of the button.

    'url'=>'...',       //A PHP expression for generating the URL of the button.

    'imageUrl'=>'...',  //Image URL of the button.

    'options'=>array(), //HTML options for the button tag.

    'click'=>'...',     //A JS function to be invoked when the button is clicked.

    'visible'=>'...',   //A PHP expression for determining whether the button is visible.


Just like this:

'buttonID' => array





thanks I use ‘click’ to direct javascript function