I tried to use $data in a grid view column inside CHtml link as below:
array(
'name' => 'title',
'type' => 'raw',
'value' => 'CHtml::link(CHtml::encode($data->title), array("#"), array("submit"=>array("/users/admin"), "params" => array("id"=>$data->id)))',
),
to send a post request to users/admin on click of the title. But $data->id returned the row number instead of the model id i.e., whether I click on the first row of the first page or the first row of the second page, I’m getting $data->id as 1 (similarly 2 for the second row and so on).
However when I try to send the same id through get request as below
CHtml::link(CHtml::encode($data->title), array("/users/admin", "id"=>$data->id))
or when displaying the ID as such in the grid view column, I’m getting the correct value of the model id for all rows.
Why am I not getting proper value when I use it in params? Is this the expected behaviour of TbGridView?