Exemple #1
0
?>
<div class="user-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create User', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
$columns = [['class' => 'yii\\grid\\SerialColumn'], 'username', 'email:email', ['attribute' => 'role', 'value' => function ($data) {
    if (isset($data->user_role->role_desc)) {
        return $data->user_role->role_desc;
    } else {
        return 'ไม่ทราบสิทธิ';
        //
    }
}, 'filter' => \yii\helpers\ArrayHelper::map(backend\models\UserRole::find()->all(), 'role_name', 'role_desc')], 'created_at', 'updated_at', ['class' => 'yii\\grid\\ActionColumn']];
echo kartik\grid\GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => true, 'pjaxSettings' => ['options' => ['enablePushState' => false]], 'responsive' => true, 'hover' => true, 'panel' => ['before' => ''], 'columns' => $columns]);
?>

</div>
Exemple #2
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create User', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'username', 'email:email', ['attribute' => 'role', 'value' => function ($data) {
    if (isset($data->user_role->role_desc)) {
        return $data->user_role->role_desc;
    } else {
        return 'ไม่ทราบสิทธิ';
        //
    }
}, 'filter' => \yii\helpers\ArrayHelper::map(backend\models\UserRole::find()->all(), 'role_id', 'role_desc')], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>