Yii Framework Forum: Progress Bar In Pagination - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Progress Bar In Pagination Rate Topic: -----

#1 User is offline   trileletri 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 12-January 12

Posted 25 October 2012 - 12:25 PM

I have a _view.php page which displays items from database, one of things that is displayed is progress bar

But when pagination occurs, when i click next page, there is no progress bar rendered, when i go back to the first page it doesn't render previously rendered progress bars.

This is what I use to render each item:
    
//I calculate the $pb_value in
    <div class="projectstat">
     $this->widget('zii.widgets.jui.CJuiProgressBar', array(
      'value'=>$pb_value,
      'htmlOptions'=>array(
       'style'=>'height:20px; width:204px; margin:auto; display:block;'
       ),
       ));?>
   </div>


What is the problem here? I guess pagination somehow ruins the progress bar logic?
0

#2 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,165
  • Joined: 05-January 12
  • Location:Morocco

Posted 25 October 2012 - 04:40 PM

Sort of, but it's JS code in general, so you have to register again your JS codes in the afterAjaxUpdate property
0

#3 User is offline   trileletri 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 12-January 12

Posted 29 October 2012 - 01:56 AM

Yes, it is the solution. but, how should that function look like? Can you provide some simple example?

My controller is making dataprovider, it is rendered in CListView using _view.php from index.php

Once page is rendered, $this->widget() code I posted above, which is located in _view.php produces divs which are named yw1, yw2, yw3... and yw0 is div which holds all items.

I managed to reinit the progress bar putting something like this
$(#yw1).progressbar({'value:0'})
$(#yw2).progressbar({'value:0'})
.
.
.

into afterajaxupdate property, but I calculate values in php, from certain data I have from database.

TL;DR; i can get progressbars to show up, but I can't reinit their values.
0

#4 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,165
  • Joined: 05-January 12
  • Location:Morocco

Posted 29 October 2012 - 06:51 AM

So you returns values in PHP? Good. You can either return them in a JSON array and use them in your JS code, or even write them into hidden divs.

If you still can't see how to do it, please post your relevant view(s) and controller codes.
0

#5 User is offline   trileletri 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 12-January 12

Posted 19 November 2012 - 12:40 PM

Ohhh I got stuck, I need to reinit my progress bars but can't quite get it.

This is my index.php (from view directory):

<?php $this->widget('zii.widgets.CListView', array(
	'dataProvider'=>$dataProvider,
	'afterAjaxUpdate' => 'reinstallProgressBar',
	'itemView'=>'_view',
	'sortableAttributes'=>array(
        'name',
        // 'location->location_name'=>'Location',
        'idcategory',
    ),
	'template'=>'{sorter}{items}<br style="clear:both"><div style="margin-top:20px !important;>"{pager}{summary}</div>',
    'pager' => array('header'=>'',),
	'summaryText'=>'',
)); ?>
</div>
<?php echo $this->renderPartial('../layouts/sidebar_cat'); ?>

<?php 
Yii::app()->clientScript->registerScript('re-install-progress-bar', "
function reinstallProgressBar(id, data) {
    jQuery('#yw1').progressbar({'value':0});
    jQuery('#yw2').progressbar({'value':0});
    jQuery('#yw3').progressbar({'value':0});
    jQuery('#yw4').progressbar({'value':0});
    jQuery('#yw5').progressbar({'value':0});
    jQuery('#yw6').progressbar({'value':0});
    //alert(id);
    // alert(data);
}
");
?>


This is my _view.php
 <?php
      $pb_value=0;
      if($data->funding->current_funds <= $data->funding->funding_goal)
      {
        $pb_value = (($data->funding->current_funds * 100) / $data->funding->funding_goal);
      }
      else
      {
        $pb_value=100;
     }
     $this->widget('zii.widgets.jui.CJuiProgressBar', array(
      'value'=>$pb_value,
      'htmlOptions'=>array(
       'style'=>'height:20px; width:204px; margin:auto; display:block;'
       ),
       ));?>


As you can see, my progress bar value is calculated in _view.php file, but afterajaxupdate calls reinstallprogressbar in index.php, and I can not pass values to it in order to correctly reinit progress bars, (they are re-initalised, but I can not get the values, they are all = 0).
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users