Pagination For A Table Contents In Yii
I'm using Yii application. In that how to give pagination to a table contents (not using cgridview). In view, =>array(
// this is used in contact page'adminEmail'=>'webmaster@example.com',
'listPerPage'=> 10,//default pagination size
),
Now, modify your controller's action like:
publicfunctionactionOutbox() {
$criteria = new CDbCriteria;
$criteria->condition = 'from_userid = :id';
$criteria->order = 'time DESC';
$criteria->params = array (':id'=>Yii::app()->user->id);
$item_count = Email::model()->count($criteria);
$model = Email::model()->findAll($criteria);
$pages = new CPagination($item_count);
$pages->setPageSize(Yii::app()->params['listPerPage']);
$pages->applyLimit($criteria);
$this->render('outbox', array(
'model' => $model,
'item_count'=>$item_count,
'page_size'=>Yii::app()->params['listPerPage'],
'items_count'=>$item_count,
'pages'=>$pages,
));
}
Then in your view after foreach
loop add CLinkPager widget, like:
<?php$this->widget('CLinkPager', array(
'currentPage' => $pages->getCurrentPage(),
'itemCount' => $item_count,
'pageSize'=> $page_size,
'maxButtonCount' => 5,
//'nextPageLabel' =>'My text >','htmlOptions' => array('class'=>'pages'),
));
?>
Thats all you need to do, you might have to do some css changes though, hope that helps :)
Element?
I have a table and I need the cells to have an element posi…
Here's a js fiddle of what I currently have, I am tryin…
So I have a few pictures that I want to randomly generate o…
This is my first question. I usually try to research these …
Right Floated Element Disappears When Using Columns In Firefox
I am using an ol element with column-count and column-gap p…
Setting Link Href From Child Image Src Using JQuery
I am using .wrap() to create a link around each image withi…
How To Limit The Html Table Records In Each Page
I am populating a table in my jsp which has more than 20 re…
I want to show countdown in each of my divs. Right now I ge…
Retain Dynamically Created DropDown List's Selected Value On Event Window.history.back()- JavaScript
Can use the below question as a reference to explain the co…
|
Post a Comment for "Pagination For A Table Contents In Yii"