简体   繁体   中英

Yii CgridView how to update with ajax

i have a CgridView thats being loaded on ajax inside a modal, i want the pagers and filters to update the data via ajax (for now is just making an url request which changes the page to the url that only shows the cgridview). I know the widget has ajaxUpdate property but i don't know how to use it and i'm not sure if what i'm looking is what the property can do.

the widget:

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'champions-grid',
    'dataProvider'=>$dataProvider,
    'itemsCssClass'=>'table',
    'columns'=>array(
        'Name',
        'AttackDamage',
        'AttackSpeed',
    ),
));

Update: I found out this widget uses it's own javascript library, but as it is being loaded via ajax (sorry for not to mention it earlier), the javascript is not loaded, however i know this won't tell how to make updates via ajax, i just thought i had to write this down here.

you would need to add

'ajaxUpdate'=>true,

So that code should look like

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'champions-grid',
    'dataProvider'=>$dataProvider,
    'ajaxUpdate'=>true,
    'itemsCssClass'=>'table',
    'columns'=>array(
        'Name',
        'AttackDamage',
        'AttackSpeed',
    ),
));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM