zenith
(Southsidestar)
January 10, 2011, 9:47am
1
Hi,
I’m pretty new with Yii and i’ve problems with sortableAttributes (maybe i dont know how to set them correctly)
My problem is that when i try to sort it doesn’t update the view. I dont know if I should somehow use DBCriteria or am i doing something else wrong. I would really appreciate if somebody could help me to set sorting work.
Controller:
$dataProvider=new CActiveDataProvider('Customer', array(
'pagination'=>array(
'pageSize'=>20,
),
));
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
View:
<?php $this->widget(‘zii.widgets.CListView’, array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'enableSorting'=>'true',
'sortableAttributes'=>array(
'firstname',
'lastname',
'created',
),
)); ?>
KEo
(Krzysztof Maziarz)
January 16, 2011, 5:33pm
2
For me everything seems fine. Check out what the ajax requests are. Alternatively you can disable javascript in your browser to perform regular request while sorting.
I’ve got a problem with sorting when have defined dbCriteria with specified ‘order’ clause.
Hope this helps somehow :>.
kassiuz
(Rios Nicolas)
February 10, 2011, 2:25pm
4
viter:
use GET instead of POST
Men, do you have some examples about it or its possible to give me help?
I’ve the same problem, bcs when I made the View and set the widget, I do not where else to do.
Plse, help me.
This is my script:
Controller (ContentController attached):
$models = new CActiveDataProvider('ContentArticles', array(
'pagination' => array(
'pageSize' => 5
),
'criteria'=>array(
'order'=>'modified DESC'
)
));
$this->render('index',array('models'=>$models));
View (index attached):
$this->widget('zii.widgets.CListView', array(
'dataProvider' => $models,
'itemView' => '_article', // refers to the partial view named '_article'
'sortableAttributes' => array(
'modified',
'title',
'sections_id',
),
'sorterHeader' => 'Ordenar por: ',
'enableSorting' => true,
'template' => "{sorter}\n<br/>{items}\n<br/><center>{pager}</center>",
'pager' => array(
'header' => '',
'firstPageLabel' => '<<',
'lastPageLabel' => '>>',
'prevPageLabel' => '< Anterior',
'nextPageLabel' => 'Siguiente >',
),
));
Partial View (_article):
echo CHtml::link(CHtml::encode($data->title),array('/content/article', 'id' => $data->id))."<br/>";
echo $data->introtext;
echo $data->fulltext;