通过Ajax更新CGridView外部的区域

时间:2013-08-02 21:04:16

标签: ajax yii

我正在使用CGridview并在Ajax调用后更新网格。然而,在我进入网格之前,我有一个小标题和一个计数$model->itemCount来识别有多少记录。我如何另外尝试与网格一起更新这条信息。它会是一个单独的JS调用吗?

感谢任何帮助

这是我目前的网格代码

'click'=>"function(){
    $.fn.yiiGridView.update('item-grid', {
        type:'POST',
        url:$(this).attr('href'),
        success:function(message) {
            $('#Ajax-Flash').html(message).fadeIn().animate({opacity: 1.0}, 3000).fadeOut('slow');
            $.fn.yiiGridView.update('item-grid');
        }
    })
    return false;
}",

1 个答案:

答案 0 :(得分:0)

不确定这是你想要的,但你可以在CgridView中使用beforeAjaxUpdate(),如下所示

<?php
    $this->widget('zii.widgets.grid.CGridView', array('id'=>'insurance_grid',
'beforeAjaxUpdate'=>"function(id, data){
//Your code to update the title and count
}",
'dataProvider'=>$model->search(),
    //'filter'=>$model,
'summaryText' => '', // 1st way
'template' => '{items}{pager}', // 2nd way
'selectableRows' => 2,
'selectionChanged' => "
function(id){

}",
'columns'=>array(array('id'=>'selectedCompanies',
'class'=>'CCheckBoxColumn',

    array('name'=>'Agency Name',
'type'=>'raw',
'value'=>'$data->agencyname',

),
),

));
?>
相关问题