IT-образование
- 4 ответа
- 0 вопросов
10
Вклад в тег
$sql = 'SELECT F_ID, F_Name FROM tbl_department;';
$rawData = Yii::app()->db->createCommand($sql);
$count = Yii::app()->db->createCommand('SELECT COUNT(*) FROM (' . $sql . ') as count_alias')->queryScalar();
$model = new CSqlDataProvider($rawData, array(
'keyField' => 'F_ID',
'totalItemCount' => $count,
'sort' => array(
'attributes' => array(
'F_ID'
),
'defaultOrder' => array(
'F_ID' => CSort::SORT_ASC,
),
),
'pagination' => array(
'pageSize' => 10,
),
));
$this->render('anActionView', array(
'model' => $model,
));
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'a-grid-id',
'dataProvider' => $model,
'ajaxUpdate' => true,
'filter' => null,
'columns' => array(
array(
'header' => 'Айди',
'name' => 'F_ID',
),
array(
'header' => 'Имя',
'name' => 'F_Name',
),
),
));