Last active
December 21, 2015 07:09
-
-
Save ZhandosKz/6269679 to your computer and use it in GitHub Desktop.
TbJsonGridView example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Controller | |
class TestController extends CController | |
{ | |
public function actionIndex() | |
{ | |
$items = array( | |
array('id' => 1, 'name' => 'Debora'), | |
array('id' => 2, 'name' => 'Joshua'), | |
array('id' => 3, 'name' => 'Kristina'), | |
array('id' => 4, 'name' => 'Albert'), | |
array('id' => 5, 'name' => 'Peter'), | |
array('id' => 6, 'name' => 'John'), | |
array('id' => 7, 'name' => 'Anna'), | |
array('id' => 8, 'name' => 'Katrine'), | |
array('id' => 9, 'name' => 'Alex'), | |
array('id' => 10, 'name' => 'Andrew'), | |
array('id' => 11, 'name' => 'Mike'), | |
array('id' => 12, 'name' => 'Nicolas'), | |
array('id' => 13, 'name' => 'Joshua'), | |
array('id' => 14, 'name' => 'Alexia'), | |
array('id' => 15, 'name' => 'Edgar'), | |
); | |
if (Yii::app()->request->isAjaxRequest) | |
{ | |
echo $this->renderPartial('index', array( | |
'dataProvider' => new CArrayDataProvider($items, array( | |
'pagination' => array( | |
'pageSize' => 5 | |
) | |
)) | |
), true); | |
Yii::app()->end(); | |
} | |
$this->render('index', array( | |
'dataProvider' => new CArrayDataProvider($items, array( | |
'pagination' => array( | |
'pageSize' => 5 | |
) | |
)) | |
)); | |
} | |
} | |
// View test/index.php | |
/** | |
* @var TestController $this | |
* @var CArrayDataProvider $dataProvider | |
*/ | |
// Example: default template | |
$this->widget('bootstrap.widgets.TbJsonGridView', array( | |
'dataProvider' => $dataProvider, | |
)); | |
// Example: haven't summary in template, for run comment the upper widget and uncomment the bottom widget | |
/* | |
$this->widget('bootstrap.widgets.TbJsonGridView', array( | |
'dataProvider' => $dataProvider, | |
'template' => '{pager}{items}{pager}' | |
)); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment