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'=>'POST',
'update' => '#DoItemList',
)
); ?>
<div class ="row" id="DoItemList">
<?php $this->renderPartial('_doItemList',array('isDisplay'=>false,'doDetailList'=>null,
));?>
</div>
My Controller :
public function actionEntryDoItem()
{
$item = new DoDetail;
$item->DoFK = $_POST['DeliveryOrder']['ID'];
$item->ProductFK = $_POST['DeliveryOrder']['ProductTemp'];
$item->Qty = $_POST['DeliveryOrder']['QtyTemp'];
$item->save();
$doDetailList = new CActiveDataProvider('DoDetail',
array(
'criteria'=>array(
'condition'=>'DoFK='.$_POST['DeliveryOrder']['ID'],
),
));
$data = array();
$data['isDisplay'] = true;
$data['doDetailList'] = $doDetailList;
$this->renderPartial('_doItemList',$data,false,true);
}
My Partial View :
if($isDisplay == true)
{
echo '<hr></hr>';
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'DODetail-grid',
'dataProvider'=>$doDetailList,
'columns'=>array(
'ProductFK',
'Qty',
array(
'class'=>'CButtonColumn',
'template'=>'{Delete}',
'buttons'=>
array('Delete'=> array(
'label'=>'Hapus',
'url'=>'Yii::app()->createUrl("DeliveryOrder/DeleteItem",array("id" => $data->ID))'
)),
),
),
));
echo '<hr></hr>';
}
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