Controller:
private function preencheCarrinho(){
$encomendaLinhasProvider = new CActiveDataProvider('EncomendaLinha', array(
'criteria' => array(
'condition' => 'encomenda=:encomenda',
'params' => array(':encomenda' => $_SESSION['encomenda']),
),
'pagination' => array(
'pageSize' => 10,
),
));
return $encomendaLinhasProvider;
}
public function actionDeleteLinha($id)
{
if(Yii::app()->request->isPostRequest)
{
// we only allow deletion via POST request
$enclinha=EncomendaLinha::model()->findByPk($id);
$enclinha->delete();
$this->renderPartial('_carrinho',array('encomendaLinhasProvider'=>$this->preencheCarrinho()));
}
else
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
}
partial view:
<script type="text/javascript">
$(function(){
$('.summary').remove();
});
</script>
<?php
Yii::import('application.modules.admin.models.Ritmo');
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'encomenda-linha',
'dataProvider' => $encomendaLinhasProvider,
'htmlOptions' => array('style' => 'padding:0'),
'columns' => array('ritmo.artist',
'ritmo.title',
array(
'header' => Yii::t('app', 'Price'),
'name' => 'ritmo.price',
'htmlOptions' => array('style' => 'width:10px;'),
'value' => '$data->ritmo->price." €"'
),
array(
'class' => 'CButtonColumn',
'template' => '{delete}',
'buttons' => array(
'delete' => array(
'url' => 'Yii::app()->createUrl("encomenda/deletelinha",array("id"=>$data->idencomenda_linha))',
'imageUrl' => Yii::app()->request->baseUrl . '/images/cross.png',
)),
'deleteConfirmation'=>Yii::t('app','Are you sure you want to delete the style?'),
)
)
));
?>
<div id="resume" style="float:right;">
<table style="background-color: #5E747B">
<tr>
<td><?php echo Yii::t('app', 'Amount :') ?></td>
<td style="text-align: right;"><?php echo $encomendaLinhasProvider->data[0]->enc->totalValue . ' €' ?></td>
</tr>
<tr>
<td><?php echo Yii::t('app', 'PayPal Fee (if aplicable) :') ?></td>
<td style="text-align: right;"><?php $valor=$encomendaLinhasProvider->data[0]->enc->totalValue + ($encomendaLinhasProvider->data[0]->enc->totalValue * 3.4 / 100) + 0.35;
echo number_format($valor, 2, ',', ' ') . ' €' ?></td>
</tr>
</table>
</div>
the problem is that when i delete an item doesnt refresh the div with the id="resume",just the table.