how do i change the alignment of yii framework pager? - php

<?php
$this->widget('zii.widgets.CListView', array(
'dataProvider' => $dataProvider,
'itemView' => '_view',
'ajaxUpdate' => true,
'pager' => array(
'class' => 'CLinkPager',
),
'template' => '{pager}{items}',
));
?>
after executing this the pager components are displaying as column format.is their any way to change that into row format?

I guess you getting this widget through renderPartial() method. When using the renderPartial() method controller not sending js and css files with response by default. If you want to get response with these files you should pass true in fourth parameter:
$this->renderPartial('myView',array(), false, true);

Related

Yii Framework: Pagation Callback Method

I have a CListView on a page and every time i navigate to page 2 or any other page I want to call a method that formats the view. But it do not seem to work every time I navigate to another page.
The Javascript method I want to call is called updateDivs()
Here is my list view widget
$this->widget('zii.widgets.CListView', array(
'dataProvider' => $dataProvider,
'itemView' => '_customview',
'id' => 'bannerslist',
'ajaxUpdate' => true,
'afterAjaxUpdate' => ' updateDivs()',
'enablePagination' => true,
'itemsCssClass' => 'row banners-list',
'summaryText' => 'Total ' . $pages->itemCount . ' Results Found',
'pager' => array(
'header' => '',
'prevPageLabel' => '<',
'nextPageLabel' => '>',
),
));
Please try this to test, it should works well.
'afterAjaxUpdate' => 'js:function(id,data){alert("test");}'
So if this code will works perfect then you should search problem in your updateDivs() function
Your problem is that, you missed to write js:function(id, data) which is significant to call a method.
You can use as follows :
'afterAjaxUpdate'=>'js:function(id, data) {updateDivs();}',
Look here for more info.

Filter CGridView (TbGridView) when using uniqid()

For my GridView I'm using uniqid() to avoid duplicate Ajax requests.
The problem is, that when I'm using filters the GridView will disappear. Same thing happens when I delete an element in the table. What I'm doing wrong?
My GridView:
$gridId = uniqid('category-mapping-grid');
$this->widget('bootstrap.widgets.TbGridView', array(
'id' => $gridId,
'filter' => $model,
'dataProvider' => $dataProvider,
...
));

RenderPartial CActiveDataProvider pagination ajax not working yii

My controller code
public function actionRead() {
$criteria=new CDbCriteria(array(
'order'=>'id desc',
));
$enP=new CActiveDataProvider('Readss', array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=>1,
),
));
$this->renderPartial('_read', array('data'=>$enP));
}
it display the gridview properly ,
my view code
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'dfsdfsdf',
'dataProvider' => $data,
'itemsCssClass' => 'sdfsdfdl',
'ajaxUpdate' => false,
'template' => '{summary}{pager}{items}{summary}{pager}',
'columns'=>array(
array(
'header'=>'#',
'value'=>'++$row',
'htmlOptions'=>array(
'style'=>'width:50px;'
)
),
'name',
array(
'name'=>'Date',
'header'=>'Date',
'value'=>'Yii::app()->dateFormatter->format("d MMM y",strtotime($data["work_date"]))'
),
),
));
But when i click my pagination my page is refressing , what mistake i did here ,
I want to load data on click pagination without page refresh.
Hope this would work you can just make the 4rd argument true
//This will disable jquery being loaded again (use this if you have jquery already loaded
//means you are calling this in ajax)
//Yii::app()->clientScript->scriptMap['jquery.js'] = false;
//Yii::app()->clientScript->scriptMap['jquery.min.js'] = false;
$this->renderPartial('_read', array('data'=>$enP),false,true);
In your CGridView you indicated to disable AJAX by following line:
'ajaxUpdate' => false,
You must change it to TRUE:
'ajaxUpdate' => true,

Append some html text to a Yii Widget

I have the following Yii widget and want to pass some html at the just before and just after the items are iterated through- can anyone explain how I do this?
$this->widget('application.widgets.zii.ListViewShowAll', array(
'summaryText' => false,
'template' => '{items}',
'htmlOptions' => array(),
'itemView' => 'application.views.widgets.account.prizes._mainprizeItem',
);
Just amended the widget code above...
'template' => '{<p>someting</p> items <p>more text</p>}',

Changing page labels (clistview, cgridview) witout changing pager css (bootstrap)

When I set 'pager' in CGridView it change bootstrap look, I try with cssFile to null or false, it doesn't work.
'pager' => array(
'class' => 'CLinkPager',
'firstPageLabel' => '<<',
'prevPageLabel' => 'smthprev',
'nextPageLabel' => 'smthnext',
'lastPageLabel' => '>>',
),
The Bootstrap extension checks if htmlOptions['class'] is set , i.e : isset($htmlOptions['class']), so if we set empty class, then it should work. So add this:
'pager' => array(
// rest of code
'htmlOptions'=>array('class'=>'')
),

Categories