Sample Category GridView In Yii2.0
<?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'categoryid', 'categoryname', 'parentid', 'createdon', // 'isactive', ['class' => 'yii\grid\ActionColumn'], ], ]); ?>
Gridview Options In Yii2.0
<?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], ......... ['class' => 'yii\grid\ActionColumn'], ], 'options'=>['class'=>'grid-view gridview-newclass'], ]); ?>
Table Options In Yii2.0
<?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], ......... ['class' => 'yii\grid\ActionColumn'], ], 'tableOptions' =>['class' => 'table table-striped table-bordered'], ]); ?>
Table Row Options In Yii2.0
<?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], ......... ['class' => 'yii\grid\ActionColumn'], ], 'rowOptions'=>function ($model, $key, $index, $grid){ $class=$index%2?'odd':'even'; return array('key'=>$key,'index'=>$index,'class'=>$class); }, ]); ?>
Gridview Layout Format In Yii2.0
<?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'layout'=>"{sorter}\n{pager}\n{summary}\n{items}", 'columns' => [ ['class' => 'yii\grid\SerialColumn'], ......... ['class' => 'yii\grid\ActionColumn'], ], ]); ?>
Gridview Summary Text, showFooter, showHeader In Yii2.0
<?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'summary'=>'', 'showFooter'=>true, 'showHeader' => true, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], ......... ['class' => 'yii\grid\ActionColumn'], ], ]); ?>
Show/Hide GridView On Empty In Yii2.0
<?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'showOnEmpty'=>true, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], ......... ['class' => 'yii\grid\ActionColumn'], ], ]); ?>