refer this and this
Even this simplest form is not working
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'profileGrid',
'dataProvider'=>$dataProvider,
'columns'=>array(
'Id',
'ShortTitle',
'SortOrder',
array(
'type'=>'raw',
'value'=>'CHtml::ajaxLink(CHtml::image("' . Yii::app()->request->baseUrl . '/images/uparrow.png","",array("border"=>0)),Yii::app()->createUrl("/product/reposition"),array(
"data"=>array(
"id"=>$data->Id,
"direction"=>"up",
"sortOrder" =>$data->SortOrder,
),
"update"=>"#profileGrid",
))." ".
CHtml::ajaxLink(CHtml::image("' . Yii::app()->request->baseUrl . '/images/downarrow.png","",array("border"=>0)),Yii::app()->createUrl("/product/reposition"),array(
"data"=>array(
"id"=>$data->Id,
"direction"=>"down",
"sortOrder" =>$data->SortOrder,
),
"update"=>"#profileGrid",
));',
),
Can you tell me why the Id in js script is not referring to the current row Id after the ajax call?
Id is the primary key. But I need to parse in the right Id to the controller to update the new sort order.
I will make this clearer…
First time load
Id | Sort Order | Title
38 | 1 | apple (click down button on this row, controller receive Id as 38, so I can swap the sortorder)
25 | 2 | banana
72 | 3 | citrus
After click, the Ajax refreshed (correctly shown on the grid)
Id | Sort Order | Title
25 | 1 | banana (click down button on this row, controller STILL receive Id as 38, it shouldn’t be 25?)
38 | 2 | apple
72 | 3 | citrus
When the controller still refers to the original Id(38) after the grid is reloaded, I cannot update the "banana(25)" Sort order…
The first time I click on a button on any line, the controller got the right Id. Subsequently after the grid reloaded, click on anywhere gives the same Id as the previous button click. It is as the data->Id is cached or the CDATA script is not updated to reflect the new sort position…
Did I do something wrong?