Yii Framework Forum: [EXTENSION] AlphaPager - Yii Framework Forum

Jump to content

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] AlphaPager Simple alphanumeric pager Rate Topic: ***** 2 Votes

#41 User is offline   CoLT 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 246
  • Joined: 22-November 09

Posted 14 November 2010 - 03:37 PM

Great news, keep it up! ;)

Greetings,
CoLT
1

#42 User is offline   Yeti 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 95
  • Joined: 30-May 09

Posted 25 November 2010 - 06:48 AM

Superb extension!!

One thing (I think bug) I have found is when using ApArrayDataProvider with ApGridView and filtering by letter, the total number of items shown in the grid summary text remains at the total of the full data set.

For example, if I have 10 items and 3 begin with C, when clicking on C I get just the 3 items shown, but the summary text in the grid shows 10 as the total.

The fix I have made is to add the following line at the end of ApArrayDataProvider::alphaFilterData()
$this->setTotalItemCount(count($this->rawData));

1

#43 User is offline   Alexander Radionov 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 23-November 10
  • Location:Russia, Novosibirsk

Posted 25 November 2010 - 06:58 AM

Great. Thank you!
0

#44 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 27 November 2010 - 02:47 PM

View PostYeti, on 25 November 2010 - 06:48 AM, said:

Superb extension!!

One thing (I think bug) I have found is when using ApArrayDataProvider with ApGridView and filtering by letter, the total number of items shown in the grid summary text remains at the total of the full data set.

For example, if I have 10 items and 3 begin with C, when clicking on C I get just the 3 items shown, but the summary text in the grid shows 10 as the total.

The fix I have made is to add the following line at the end of ApArrayDataProvider::alphaFilterData()
$this->setTotalItemCount(count($this->rawData));



Hi Yeti,

thanks for your report. I see... yes, this could happen if you have requested the totalItemCount in your app before alphaFilterData() was called. Because once calculated it will not be recalculated when the grid is created (this is up to CDataProvider).

So i think it's a good idea to refresh the count like you have mentioned! But i'd prefer to use
$this->getTotalItemCount(true);
for this, so the internal calculateTotalItemCount() function is used.

Bug #2:
While playing around to figure out yeti's problem i've found another bug that shows up when disabling pagination. The GridView will create a row for every item of the original dataset just leaving those blank which don't fit to the selected alphapager letter.

I'll fix these two issues and upload a new version of alphapager.

Thank you!

Best regards
0

#45 User is offline   Daniel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 206
  • Joined: 26-September 09

Posted 02 March 2011 - 03:47 AM

Dear All,

I combine alpha pager with pageSize (http://www.yiiframew...ze-in-cgridview). The thing is if I combined with alpha pager, the pagesize is coming back to default size which I set as 10.

For example, I am in letter "A", and there are 70 items. If the pageSize is set to 10, then only 10 items are displayed. I change the pageSize to 25, it will be correct, the 70 items are split into 3 pages, but if I am click on page 2, the pageSize back to default 10, so it becomes 7 pages.

Any help on this?

Cheers,

Daniel
0

#46 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 02 March 2011 - 03:09 PM

Hello Daniel,

i've checked using AlphaPager together with the "DropDown for pageSize in CGridView".
If you have defined the pagination as the subpagination of AlphaPager - something like:

ApActiveDataProvider(get_class($this), array(
			'alphapagination'=>array(
           	'pagination'=>array(
               	  'pageSize'=> Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']),
		   	),
           	...
       	),
      	...
);


you stepped on a bug. The additional parameters used for configuring the subpagination are ignored if defined like this and not set for the resulting pagination object.

I've fixed this bug in ApPagination and will upload a new version to the extension repository within the next hour.

Hopefully this solves your issue! Otherwise just reply or send me a pm.

Best regards
0

#47 User is offline   Daniel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 206
  • Joined: 26-September 09

Posted 03 March 2011 - 09:58 AM

Hi Yoshi,

what would be the differences when using subpagination or not? below is the return value of my model search:

 return new ApActiveDataProvider(get_class($this), array(
                'criteria'=>$criteria,
                'alphapagination'=>array(
                    'attribute'=>'name',
                    'activeCharSet'=>$activeChars
                ),
                'pagination'=>array(
                    'pageSize'=> Yii::app()->user->getState('pageSize',
                                     Yii::app()->params['defaultPageSize']),
                ),
            ));


and below is my portion of code in the controller:

...
        if (isset($_GET['pageSize'])) {
            Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
            unset($_GET['pageSize']);
        }
        else {
            Yii::app()->user->setState('pageSize',Yii::app()->params['defaultPageSize']);
        }

...
        $merge=new CDbCriteria;
        if(!Yii::app()->request->isAjaxRequest)
                $merge->order = '`name` ASC';
...


I guess I understand my problems:

1. My dropdown pageSize error caused by this else clause

        else {
            Yii::app()->user->setState('pageSize',Yii::app()->params['defaultPageSize']);
        }


2. Page error confusion (sorting problem maybe) caused by

      if(!Yii::app()->request->isAjaxRequest)
                $merge->order = '`name` ASC';


since pager request is ajax, the order result will be different if with the one if the page is requested by non-ajax one.

It seems my problems are solved so far...

thx a lot for your help.

cheers,

Daniel


View Postyoshi, on 02 March 2011 - 03:09 PM, said:

Hello Daniel,

i've checked using AlphaPager together with the "DropDown for pageSize in CGridView".
If you have defined the pagination as the subpagination of AlphaPager - something like:

ApActiveDataProvider(get_class($this), array(
			'alphapagination'=>array(
           	'pagination'=>array(
               	  'pageSize'=> Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']),
		   	),
           	...
       	),
      	...
);


you stepped on a bug. The additional parameters used for configuring the subpagination are ignored if defined like this and not set for the resulting pagination object.

I've fixed this bug in ApPagination and will upload a new version to the extension repository within the next hour.

Hopefully this solves your issue! Otherwise just reply or send me a pm.

Best regards

0

#48 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 03 March 2011 - 02:15 PM

Hello Daniel,

View PostDaniel, on 03 March 2011 - 09:58 AM, said:

what would be the differences when using subpagination or not?


There wouldn't be any differences. If you define the pagination as a part of AlphaPager (the so called subpagination) for a DataProvider then AlphaPager will just pass the pagination on to the DataProvider.
To show some code:
return new ApActiveDataProvider(get_class($this), array(
'alphapagination'=>array(
	....
),
'pagination'=>array(        
	'pageSize'=> 10, 
),
));


and

return new ApActiveDataProvider(get_class($this), array(
'alphapagination'=>array(
	....
	'pagination'=>array(        
    	'pageSize'=> 10, 
	),
),
));


are the same.

View PostDaniel, on 03 March 2011 - 09:58 AM, said:

It seems my problems are solved so far...


These are always good news. Your first issue was definitely the ELSE-clause, because the pageSize value is only sent, when it's changed.

Cheers
0

#49 User is offline   Daniel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 206
  • Joined: 26-September 09

Posted 05 March 2011 - 05:56 PM

Hi Yoshi,

just wondering, how could I change the text "Go to letter", I tried "header"=>"Index" but not working.

Cheers,
0

#50 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 06 March 2011 - 06:55 AM

Hi Daniel,

View PostDaniel, on 05 March 2011 - 05:56 PM, said:

just wondering, how could I change the text "Go to letter", I tried "header"=>"Index" but not working.


Yes, this is the correct attribute.
Example:
<?php $this->widget('ApGridView', array(
	'id'=>'myGrid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'template'=>"{summary}\n{alphapager}{pager}\n{items}",
	'alphaPager'=>array(
 			'showNumPage'=>'true',
        	'header'=>'Index: ' //  <=====Setting different header text
	),
  ....
?>


If it doesn't work for you please post your corresponding source code, so i can take a look.

Regards
0

#51 User is offline   nix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 17-May 11

Posted 13 June 2011 - 09:39 AM

Hello,

I've just installed AlphaPager and tried to implement it on a module I'm working on,

here is what I have in Model of my controller
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.
		
		Yii::import('application.extensions.alphapager.ApActiveDataProvider');

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('sef_name',$this->sef_name,true);

		//return new CActiveDataProvider(get_class($this), array(
		return new ApActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,

			'alphapagination'=>array(
				'attribute'=>'name',
			),
		));
	}


and this is my view file,

<?php $this->widget('application.extensions.alphapager.ApListView', array(
	'dataProvider'=>$dataProvider,
	'itemView'=>'_view',
	'template'=>"{alphapager}\n{pager}\n{items}",
)); ?>


and this is the error I'm getting:
Error 500

CActiveDataProvider does not have a method named "getAlphaPagination".


Did I miss something?

P.S. Now I just previewed my code, maybe it is trying to find the extension in module/extension directory instead of root/protected/extension directory which is where I've installed the extension (so I can use it on other modules)!? --this doesn't seem to be the case
0

#52 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 13 June 2011 - 10:45 AM

Hi nix,

could it be that you have defined the $dataProvider variable inside your controller action similar to
$dataProvider=new CActiveDataProvider....
?!

You should try the following

Inside your controller action:
	public function actionYourAction()
	{
		$model=new YourModel('search');
		$model->unsetAttributes();  // clear any default values

		$this->render('YourView',array(
			'model'=>$model,
		));
	}


and inside your view:

<?php $this->widget('application.extensions.alphapager.ApListView', array(
   	'id'=>'myListView',
   	'dataProvider'=>$model->search(),
        'itemView'=>'_view',
        'template'=>"{alphapager}\n{pager}\n{items}",
   /* ... */
)); ?>


Regards
1

#53 User is offline   nix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 17-May 11

Posted 13 June 2011 - 06:57 PM

Thanks a lot yoshi, now everything works :D

You might as well want to add above code to your extension usage example, can't be certain but I'm pretty sure I followed the installation/usage manual last night when testing the extension, though because I'm using the latest yii framework I jumped into 2nd section of the manual without reading 1st section, that might be why

Next challenge is to get rid of the page numbers under alpha blocks and put pagination to the bottom of the page, guessing that this is not going to be hard
Edit: done the pagination thing, peace of cake thanks to your template variable

Cheers
0

#54 User is offline   nix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 17-May 11

Posted 13 June 2011 - 09:06 PM

Only one issue, Using ApListView in my widget I couldn't get showNumPage activated (kept giving the error of: Property "ApListView.showNumPage" is not defined.), as a last resort I changed the default value of false to true within ApLinkPager class which did the job and I actually prefer having this option enabled for all my lists
0

#55 User is offline   yoshi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 28-February 09
  • Location:Germany

Posted 16 June 2011 - 12:04 PM

Hello nix,

the showNumPage property belongs to the pager itself and not to ApListView.
You can configure the alphaPager e.g. in the following way:

<?php $this->widget('application.extensions.alphapager.ApListView', array(
        'dataProvider'=>$dataProvider,
        'itemView'=>'_view',
        'template'=>"{alphapager}\n{pager}\n{items}",
        'alphaPager'=>array('showNumPage'=>true) // <==== here
)); ?>


Regards
1

#56 User is offline   phenomfx 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 19-May 11

Posted 22 June 2011 - 09:38 PM

Great extension Thank you!
0

#57 User is offline   darkheir 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 25-July 11

Posted 25 July 2011 - 03:06 PM

I'm just begining with Yii, and i find this extension very usefull!

I was wondering if there is a simple way to not list all the entries when we are arriving on the web page:
i would like to begin with all the entries begining with an "A" for example.

Regards
My blog (in french) => http://blog.devsa.org
0

#58 User is offline   yeti999 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 19-August 11

Posted 25 October 2011 - 03:35 AM

Hi All:
I need to display the record number inside the view file of 'itemView'. I mean the ranking of the record.
Just to query like this:
SET @rank=0;
SELECT @rank:=@rank+1 AS rank, fruit, amount FROM sales ORDER BY amount DESC ;
And display that rank number in the view.

How can i do this?
0

#59 User is offline   PeRoChAk 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 570
  • Joined: 26-November 10
  • Location:Lahore, Pakistan

Posted 03 December 2012 - 10:40 PM

How can I replace the, for example alphapage=8 to alphapage=H ?
Cheers
Perochak
Web Design - Logo Design - Application Development

My Blog | Forums Comparison
0

#60 User is offline   dionyseos 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 05-August 11

Posted 28 January 2013 - 08:26 AM

Hi,

I have a question about changing ajaxUrl. At CListView, I can change the ajaxUrl like this:
array(
   ...
   'ajaxUrl' => '/controller/action'
  ...
)

But when I want to do the same change at ApListView, the ajaxUrl won´t change - I've tested the request url with firebug. Have anyone an idea about this?
0

Share this topic:


  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • You cannot start a new topic
  • You cannot reply to this topic

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