StErMi
(Stermi)
January 13, 2010, 10:06pm
1
Hi all, I was looking to the new admin view that use this wonderful layout.
My problem is this, i want to use zii.widgets.grid.CGridView passing to him only an array of items and not a CActiveDataProvider.
I’ll explain better:
I’ve the object $category. Category has a relation with post. So in $category->posts i’ve all the posts related to the category.
How can I do like in the admin view without using CActiveDataParameter? Someone can give me a code example?
Thank you very much
qiang
(Qiang Xue)
January 13, 2010, 10:26pm
2
How do you plan to do sorting and pagination then?
You could try directly setting $dataProvider->data=$items. There may still be problems if you want sorting and pagination.
StErMi
(Stermi)
January 13, 2010, 10:54pm
3
The problem is that I don’t want to do another query when I already taked from db have the items i needed.
Can’t I create only a CActiveDataProvider with the pagination and so without the criteria parameter and then assign to the CActiveDataProvider object the items with setData? When i will use the pagination widget will perform a new query or just filter the object that the ActiveDataProvider store?
seb
(Serebrov)
January 14, 2010, 7:50am
4
StErMi:
The problem is that I don’t want to do another query when I already taked from db have the items i needed.
Can’t I create only a CActiveDataProvider with the pagination and so without the criteria parameter and then assign to the CActiveDataProvider object the items with setData? When i will use the pagination widget will perform a new query or just filter the object that the ActiveDataProvider store?
There is extension arraydataprovider - you can use it to solve your task. And I am attaching modified version with pagination support - 441
CArrayDataProvider.zip
.
You can use it like this:
$dataProvider = new CArrayDataProvider(
'Post', $category->posts,
array(
'pagination'=>array(
'pageSize' => 20
)
)
);
StErMi
(Stermi)
January 14, 2010, 11:12am
6
everything works, the problem is that with your extension you can’t click on the column name to order the items on it.
I need this help too… anyone have the solution which include sorting?