Hi people !!
I have a CGridView inside a CJuiTabs for showing requests separated by status, so in the first tab are the request that have just arrived, in the second the accepted request in the third the rejected …
The CGridView has a couple of options to change its state. For example to accept a request I have something like this (the important part is on the click option):
'accept' => array(
'label'=>'Revisar',
'url' => 'Yii::app()->createUrl("problemas/moveToReviewed", array(
"id" => $data->Id_Pr,
))',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/circular_ok.png',
'options' => array('class' => 'myAcceptBtn'),
'visible'=>'$data->Id_Status == 1',
'click'=>"function(){
if (!confirm('Seguro que desea cambiar su ESTADO a REVISADO ?')) {
return false;
}
$.fn.yiiGridView.update('tbl_problem_status', {
type:'POST',
url:$(this).attr('href'),
success:function(data) {
$.fn.yiiGridView.update('tbl_problem_status');
alert('Aceptado con exito');
}
});
return false;
}",
),
wich totally works, the post request that change the row state is sent and an ajax event updates the table’s data. The table even shows its spinning wheel
but I have troubles when I have to update the CGridView with from a CJuiDialog the code goes like this:
'unidad' => array(
'label'=>'Asignar Unidad',
'url' => 'Yii::app()->createUrl("problemas/moveToSent", array(
"id1" => $data->Id_Pr,
"id2" => $data->Id_Pr,
))',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/circular_list.png',
'options' => array('class' => 'myUnidtyBtn'),
'click'=>'function() {
var id = $(this).parent().parent().find("input[name=rowid]").val();
$("#txtGridProblemId").val(id);
$("#txtGridProblemUrl").val( $(this).attr("href") );
$("#dialogRevisado").dialog("open");
return false;
}',
'visible'=>'$data->Id_Status == 2',
),
and when the user accepts the changes I have this in js code:
function changeToSentJS(){
$(this).dialog("close");
$.fn.yiiGridView.update('tbl_problem_status', {
type:'POST',
url:"<?php echo CController::createUrl('problemas/moveToSent');?>",
data: {id1:$("#txtGridProblemId").val()
, id2:$("#xtmp_select").val()
, cant:$("#xtmp_cant").val()
},
success:function(datax) {
$.fn.yiiGridView.update('tbl_problem_status', {data: 'id_status=2'});
alert("Se actualizo con exito");
}
});
return false;
}
I can see the POST request that changes the status of the request object and I can see the ajax get request that brings the table data without the row, but the data is not updated
I don’t know what to do to update the table just like with the first option…
Please, can somebody help me ?
(sorry if there are mistakes, English is not my first language)
Regards,
Sebastian