CArrayDataProvider takes an array of AR models for being used in an zii Widget like CListView.
protected/extensionsSee the following code example:
Yii::import('application.extensions.CArrayDataProvider'); $posts = User->posts; $dataProvider=new CArrayDataProvider('Post', $posts); // $dataProvider->getData() will return a list of Post objects belonging to User
Total 8 comments
An implementation of this with the same name is now included in the core as of 1.1.4
Pretty easy changeover:
Whereas with this extension I used the following:
$contactsDP = new CArrayDataProvider('Contacts', $this->model->contacts);This can now be simplified to
$contactsDP = new CArrayDataProvider($this->model->contacts);Nice extension, but there's an update for this extension to sort by column: ex sort by posts or by categories.
Thanks
if you don't have key equal to 0, you fetchKeys will not work. Please change it into following
Cheers, exactly what I was after :)
I have modified this to handle pagination correctly.
protected function fetchData() { if( ( $pagination=$this->getPagination())!==false) {
$pagination->setItemCount($this->getTotalItemCount());
$offset = $pagination->getOffset(); $limit = $pagination->getLimit(); return array_slice( $this->dataArray, $offset, $limit ); } return $this->dataArray; }
I use WinRAR and it couldn't extract bz2 :)
Just added a .zip version
but afaik winzip as winrar can extract .bz2 files under windows... :)
Not so popular format for the downloaded file (bz2) on not-*nix platforms, please use a more supported format (at least "gz" if not "zip").
Leave a comment
Please login to leave your comment.