本文介绍了Yii的cgridview ajaxUpdate财产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个cgridview在另一个cgridview:外一种是:

I have one cgridview inside another cgridview:the outer one is:

$this->widget('application.modules.user.components.CsvGridView', array(
    'dataProvider'=>$model->mySearch(),
    'filter' => $model,
    'id'=>'users-grid',
...

内的是:

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'vacr-grid',

    'dataProvider'=>$model->searchu(),
   // 'pager'=>false,
   // 'enableSorting'=>false,
    'summaryText'=>'',
    'ajaxUpdate'=>'vacr-grid',

    'columns'=>array(

        'start',
        'end',
                array(
                        'name' => 'vac_type',
                        'value' =>
                        'isset($data->vacType->name)?$data->vacType->name:$data->vac_type'
                ),
    ),
));

的问题是,所述内一个不正确地更新(当然与阿贾克斯更新)。

The problem is that the inner one does not update properly (of course update with ajax).

当我点击下一步,例如,在内部cgridview,所请求的网址是:请求的URL:http://本地主机/ ORM / VAC / VAC / adminu / USER_ID / 1 / Vac_page / 2阿贾克斯=用户网
注意到用户栅型是外cgridview的id。然后我点击下一步内和外cgridviews两个消失后。

when I click on "next" for example, in the inner cgridview, the requested URL is: Request URL:http://localhost/orm/vac/vac/adminu/user_id/1/Vac_page/2?ajax=users-grid
notice that users-grid is the id of the outer cgridview.and then after I click on "next" the inner and the outer cgridviews both disappears.

我尝试使用 ajaxUpdate财产但它没有什么影响。谢谢你。

I try to use ajaxUpdate property but it does not affect anything.thank you.

推荐答案

这是一个类似的问题之一,我有。排序和分页网址是由dataProvider中设置,而搜索URL被ajaxUrl设置。你必须将所有3使用CGridView断章取义。

This is a similar issue to one I was having. The sort and paging urls are set by the dataProvider whereas the search url is set by ajaxUrl. You have to set all 3 to use CGridView out of context.

dataProvider中单独设置:

dataprovider set separately:

$dataProvider=new CActiveDataProvider('Modelname',array(
    'criteria'=>$criteria,
    'pagination'=>array(
        'route'=>'something/search'
    ),
    'sort'=>array(
        'route'=>'something/search'
    )
));




$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'vacr-grid',    
    'dataProvider'=>$dataProvider,
    'summaryText'=>'',
    'ajaxUpdate'=>'vacr-grid', // not necessary if same as id
    'ajaxUrl'=>Yii::app()->createUrl( 'Something/search' ),  // this takes care of the search  
    'columns'=>array(    
        'start',
        'end',
                array(
                        'name' => 'vac_type',
                        'value' =>
                        'isset($data->vacType->name)?$data->vacType->name:$data->vac_type'
                ),
    ),
));

另外我类似的问题...

Also my similar question...

How我用CGridView的ajaxUrl参数的Yii?

这篇关于Yii的cgridview ajaxUpdate财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 10:08