Yii loading dynamically added (using ajax) GridView TypeError: settings undefined

I use ajax and load content dynamically with a GridView.

It worked, but gridview js (jquery.yiigridview.js) and yiiGridView ($ options) did not load; "
And
when I use $.fn.yiiGridView, it gives an error.

If I do not use ajax, everything worked fine enter image description here

therefore, if I use dynamic content loading with ajax, I cannot reload it. $. fn.yiiGridView.update ('mygrid'); error
TypeError parameters:: undefined $ Grid.addClass (settings.loadingClass) enter image description here

this is my code: javaScipt code index (call controller and downloadable content) :

sendAjaxCall = function(url){

        request = $.ajax({
            url : url,
            type: 'GET',
            dataType: 'html',           
            success : function(data){
                var newContent = $(data).find('#content>.container').html();

                // adding only main contant
                if(newContent === null || !newContent ) {
                    $(container).html(data);
                } else {
                    $(container).html(newContent);
                }
            },
            error : function(error){
                console.log(error);
            }
        });
    }

controller:

public function actionMyFunction(){

        $condition='...'
        $dataProvider = new CActiveDataProvider('MtTable', array(
            'criteria' => array(
                'condition' => $condition,
                'order' => '',
            ),
        ));

        if(Yii::app()->request->isAjaxRequest){

            $this->renderPartial('my_view', array(
                'model' => $dataProvider,false,true
            ));


        } else {
            $this->render('my_view', array(
                'model' => $dataProvider,
            ));
        }

    }

view

<span class="h1"> <?php echo ModuleSettings::t( 'Usersettings', 'Manage Keys' ); ?></span>
<div class="wrapperlong">
    <?php
    $this->widget('bootstrap.widgets.TbExtendedGridView',array(
        'id'=>'key-grid',
        'fixedHeader' => true,        
        'responsiveTable' => false,
        'template' => "{items}{pager}{summary}",
        'ajaxUpdate'=>true,
        'ajaxUrl'=> Yii::app()->request->getUrl(),
        'afterAjaxUpdate' => 'completeAjax',
        'dataProvider'=>$model,
        'columns'=>array(
            'title',
            'key',
        )

    )); ?>
</div>

Help solve this problem.

+4
1

, :

// controller
if(Yii::app()->request->isAjaxRequest){

    Yii::app()->clientScript->corePackages = array(); //new insert

    $this->renderPartial('my_view', array(
        'model' => $dataProvider,false,true
    ));
}
+1

All Articles