Skip to content

Commit

Permalink
Dev: add pagination size selector to quotas grid (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonisOrmisson authored and Shnoulle committed Mar 15, 2017
1 parent 4b93b96 commit b11a952
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
9 changes: 8 additions & 1 deletion application/controllers/admin/quotas.php
Expand Up @@ -161,13 +161,20 @@ function index($iSurveyId, $quickreport = false)
$totalcompleted = 0;
$csvoutput = array();

// Set number of page
if (Yii::app()->getRequest()->getQuery('pageSize'))
{
Yii::app()->user->setState('pageSize',(int)Yii::app()->getRequest()->getQuery('pageSize'));
}
$aData['iGridPageSize'] = Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']);
$aData['oDataProvider'] = new CArrayDataProvider($oSurvey->quotas,array(
'pagination' => array(
'pageSize' => 20,
'pageSize' => $aData['iGridPageSize'],
'pageVar' => 'page'
),
));


//if there are quotas let's proceed
$aViewUrls['output'] = '';
if (!empty($oSurvey->quotas))
Expand Down
23 changes: 23 additions & 0 deletions application/views/admin/quotas/viewquotas_view.php
Expand Up @@ -8,10 +8,25 @@
/* @var array $aQuotaItems */
/* @var integer $totalquotas */
/* @var integer $totalcompleted */
/* @var integer $iGridPageSize */
/* @var Quota $oQuota The last Quota as base for Massive edits */
/* @var QuotaLanguageSetting[] $aQuotaLanguageSettings The last Quota LanguageSettings */


?>
<!-- To update grid when pageSize is changed -->
<script type="text/javascript">
$(document).ready(function() {
jQuery(function($)
{
jQuery(document).on("change", '#pageSize', function()
{
$.fn.yiiGridView.update('quota-grid',{ data:{ pageSize: $(this).val() }});
});
});
});
</script>

<div class='side-body <?php echo getSideBodyClass(false); ?>'>
<div class="row">
<div class="col-lg-12 content-right">
Expand All @@ -35,6 +50,13 @@
'dataProvider' => $oDataProvider,
'id' => 'quota-grid',
'emptyText'=>gT('No quotas'),
'summaryText'=>gT('Displaying {start}-{end} of {count} result(s).').' '. sprintf(gT('%s rows per page'),
CHtml::dropDownList(
'pageSize',
$iGridPageSize,
Yii::app()->params['pageSizeOptions'],
array('class'=>'changePageSize form-control', 'style'=>'display: inline; width: auto'))),

'columns' => array(
array(
'id'=>'id',
Expand Down Expand Up @@ -98,6 +120,7 @@

),
'itemsCssClass' =>'table-quotas table-striped table-condensed',
'ajaxUpdate' => true,
));
?>
</div>
Expand Down

0 comments on commit b11a952

Please sign in to comment.