Hello,
I’m adding new rows to my CGridView via an ajax form. I’d like to change the text on one of my cells to “Running…” after the new row is inserted to indicate that something is still running in the background (until the user needs to click a link to stop the process). I tried the success ajax event per a suggestion from another forum post but it seems like the row is inserted after the event is complete.
I also tried the afterAjaxUpdate event in CGridView. This seems to fire on a new row being inserted but I don’t know how to access the id of the cell (or for the record) for the newly inserted row. The id parameter returns the id of the CGridView and the data parameter returns the data for the whole page.
Here’s the code for the success event upon successful submission of form:
<!-- CODE FOR AJAX FORM -->
<script>
function success(data) {
// refresh your grid
$.fn.yiiGridView.update('timeentries-grid');
$('.fly').html('Running...');//Tried as a test but the row is not yet inserted
//.link-column '+data
alert(data);//row still not displayed
}
function failure(data) {
alert('Boom');
}
</script>
<!-- CODE FOR AJAX FORM -->
This is my CGridView
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'timeentries-grid',
'dataProvider'=>$model->search(),
'afterAjaxUpdate'=>'function(id, data){
alert(data);//returns the data for the whole page
}',
'filter'=>$model,
'filterPosition'=>'body',
'pager'=>array('pageSize'=>'3'),
'columns'=>array(
array('name'=>'project','value'=>'$data->projectfk->projectname'),
array('name'=>'projectitem','value'=>'$data->projectitemfk->projectitem'),
'date',
'notes',
array(
'class'=>'CLinkColumn',
'header'=>'Time',
'labelExpression'=>'$data->time',
'cssClassExpression'=>'$data->internalid',
//'htmlOptions'=>array('id'=>'$data->internalid'),
'linkHtmlOptions' => array('class'=>'fly')
),
array(
'class'=>'CButtonColumn',
),
),
));
?>
Thanks for your help.