ajax action in CGridView

Hi all ,

I have a problem about : how to create custom button in CGridView and add that button with ajax request??

This is my scenario :

My View :

<?php echo CHtml::ajaxSubmitButton ("

                   CController::createUrl('deliveryOrder/EntryDoItem'),


                    array('type'=&gt;'POST',


		'update' =&gt; '#DoItemList',


		)


	); ?&gt;





&lt;div class =&quot;row&quot; id=&quot;DoItemList&quot;&gt;


	&lt;?php &#036;this-&gt;renderPartial('_doItemList',array('isDisplay'=&gt;false,'doDetailList'=&gt;null,


                ));?&gt;


&lt;/div&gt;

My Controller :

public function actionEntryDoItem()

{


	&#036;item = new DoDetail;


	&#036;item-&gt;DoFK = &#036;_POST['DeliveryOrder']['ID'];


	&#036;item-&gt;ProductFK = &#036;_POST['DeliveryOrder']['ProductTemp'];


	&#036;item-&gt;Qty = &#036;_POST['DeliveryOrder']['QtyTemp'];	


	&#036;item-&gt;save();


	


	&#036;doDetailList = new CActiveDataProvider('DoDetail',


                    array(


                        'criteria'=&gt;array(


                            'condition'=&gt;'DoFK='.&#036;_POST['DeliveryOrder']['ID'],


                        ),


                    ));


	


	&#036;data = array();


	&#036;data['isDisplay'] = true;


	&#036;data['doDetailList'] = &#036;doDetailList;


	&#036;this-&gt;renderPartial('_doItemList',&#036;data,false,true);


}

My Partial View :

if($isDisplay == true)

{


	echo '&lt;hr&gt;&lt;/hr&gt;';


	&#036;this-&gt;widget('zii.widgets.grid.CGridView', array(


		'id'=&gt;'DODetail-grid',


		'dataProvider'=&gt;&#036;doDetailList,


		'columns'=&gt;array(


			'ProductFK',


	        'Qty',


			array(


                'class'=&gt;'CButtonColumn',


                'template'=&gt;'{Delete}',


                'buttons'=&gt; 


					array('Delete'=&gt; array(


						'label'=&gt;'Hapus',


						'url'=&gt;'Yii::app()-&gt;createUrl(&quot;DeliveryOrder/DeleteItem&quot;,array(&quot;id&quot; =&gt; &#036;data-&gt;ID))'


                       )),


				),


			),


		));


	echo '&lt;hr&gt;&lt;/hr&gt;';


}

SO, What i want to ask is -> How to create an action of Delete Button in CGridVeiw above to update #DoItemList ??

What i want to do is i want to give delete button ajax request so it can call a controller to update #DoItemList

Is there any suggestion or anything solution to solved this problem ? i’m very appreciate it

Thanks a lot

I’ve been trying to figure out the same thing too for a while, and can’t find example anywhere. Perhaps Yii needs an Ajax tutorial, or some more examples in the documentation.

Try:

‘click’ => ‘js:function() {Hapus_clicked( $(this).attr(“href”) ); return false;}’,

then a Hapus_clicked() js function. Check out jquery.yiigridview.js and the source of CButtonColumn.