Last active
December 6, 2017 08:10
-
-
Save Bizunow/211cdd0d39fab4a678c2f0f844740c73 to your computer and use it in GitHub Desktop.
[Yii ajax CGridView] #php, #yii
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @var $previousExportsDataProvider CArrayDataProvider | |
*/ | |
$columns = array( | |
[ | |
'header'=>CHtml::encode('Name'), | |
'name' => 'name', | |
], | |
[ | |
'header'=>CHtml::encode('Date'), | |
'name'=>'date', | |
] | |
); | |
$this->widget('zii.widgets.grid.CGridView', array( | |
'id'=>'ajax-grid', | |
'ajaxUrl' => 'instagram/renderAjaxGrid', | |
'dataProvider'=>$dataProvider, | |
'columns'=>$columns, | |
'pager' => [ | |
'firstPageLabel' => false, | |
'lastPageLabel' => false, | |
] | |
)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class InstagramController extends Controller | |
{ | |
public function actionRenderAjaxGrid() | |
{ | |
$data = []; // Array with your data | |
$this->render('_audience_exports', [ | |
'dataProvider' => new CArrayDataProvider($data) | |
]); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$this->renderPartial('_audience_exports', [ | |
'previousExportsDataProvider' => new CArrayDataProvider([]) | |
]) | |
?> | |
<button class="btn-refresh">Refresh</button> | |
<script> | |
$('.btn-refresh').click(function() { | |
$.fn.yiiGridView.update('ajax-grid'); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment