Skip to content

Instantly share code, notes, and snippets.

@ZhandosKz
Last active December 21, 2015 07:09
Show Gist options
  • Save ZhandosKz/6269679 to your computer and use it in GitHub Desktop.
Save ZhandosKz/6269679 to your computer and use it in GitHub Desktop.
TbJsonGridView example
<?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