yiicgridview

Yii - reload dynamically added CGridView


if append to page the CGridView ('myGridViewID') by ajax, I can't reload it.
$.fn.yiiGridView.update('myGridViewID');

TypeError: settings is undefined

$grid.addClass(settings.loadingClass);


Solution

  • Use renderPartial in controller action:

    $cs = Yii::app()->clientScript;
    $cs->reset();
    $cs->scriptMap = array(
        'jquery.js'  =>  false,   // prevent produce jquery.js in additional javascript data
    );
    
    // Look at 4th parameter: with TRUE value, your view will have additional javascript data.
    $this->renderPartial('_partialViewWithGrid', array(), false, true);