kartik-v / yii2-grid
Yii 2 GridView on steroids. Various enhancements and utilities for the Yii 2.0 GridView widget.
Fund package maintenance!
Open Collective
Installs: 5 349 769
Dependents: 296
Suggesters: 0
Security: 0
Stars: 556
Watchers: 57
Forks: 303
Open Issues: 26
Type:yii2-extension
Requires
- kartik-v/yii2-dialog: ~1.0
- kartik-v/yii2-krajee-base: >=3.0.3
Suggests
- kartik-v/yii2-bootstrap4-dropdown: For enabling dropdown support when using with Bootstrap v4.x
- kartik-v/yii2-bootstrap5-dropdown: For enabling dropdown support when using with Bootstrap v5.x
- kartik-v/yii2-mpdf: For exporting grids to PDF
- dev-master / 3.5.x-dev
- v3.5.3
- v3.5.2
- v3.5.1
- v3.5.0
- v3.3.6
- v3.3.5
- v3.3.4
- v3.3.3
- v3.3.2
- v3.3.1
- v3.3.0
- v3.2.9
- v3.2.8
- v3.2.7
- v3.2.6
- v3.2.5
- v3.2.4
- v3.2.3
- v3.2.2
- v3.2.1
- v3.2.0
- v3.1.9
- v3.1.8
- v3.1.7
- v3.1.6
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.9
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.9.0
- v2.8.0
- v2.7.0
- v2.6.0
- v2.5.0
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.0
- v1.9.0
- v1.8.0
- v1.7.0
- v1.6.0
- v1.5.0
- v1.4.0
This package is auto-updated.
Last update: 2024-10-15 10:08:27 UTC
README
yii2-grid
Yii2 GridView on steroids. A module with various modifications and enhancements to one of the most used widgets by Yii developers. The widget contains new additional Grid Columns with enhanced settings for Yii Framework 2.0. The widget also incorporates various Bootstrap 3.x styling options. Refer detailed documentation and/or a complete demo. You can also view the grid grouping demo here.
Docs & Demo
You can see detailed documentation, demonstration and API code documentation on usage of the extension. You can also view the grid grouping demo here.
Note: If you face an issue of bootstrap popovers loading on page load for editable columns - you can disable it by hiding the bootstrap popovers in your yii2 view layout after document ready. For example in your yii2 view layout:
<script>
$(document).on("ready", function() {
$('.popover-x:visible').popoverX('hide'); // or use the right CSS selector as per your need
});
</script>
Installation
The preferred way to install this extension is through composer.
Read this web tip /wiki on setting the minimum-stability
settings for your application's composer.json.
Pre-requisites
Install the necessary pre-requisite (Krajee Dropdown Extension) based on your bootstrap version:
- For Bootstrap v5.x install the extension
kartik-v/yii2-bootstrap5-dropdown
- For Bootstrap v4.x install the extension
kartik-v/yii2-bootstrap4-dropdown
- For Bootstrap v3.x install the extension
kartik-v/yii2-dropdown-x
For example if you are using the Bootstrap v5.x add the following to the require
section of your composer.json
file:
"kartik-v/yii2-bootstrap5-dropdown": "@dev"
Install
Either run:
$ php composer.phar require kartik-v/yii2-grid "@dev"
or add
"kartik-v/yii2-grid": "@dev"
to the require
section of your composer.json
file.
Usage
use kartik\grid\GridView; $gridColumns = [ ['class' => 'kartik\grid\SerialColumn'], [ 'class' => 'kartik\grid\EditableColumn', 'attribute' => 'name', 'pageSummary' => 'Page Total', 'vAlign'=>'middle', 'headerOptions'=>['class'=>'kv-sticky-column'], 'contentOptions'=>['class'=>'kv-sticky-column'], 'editableOptions'=>['header'=>'Name', 'size'=>'md'] ], [ 'attribute'=>'color', 'value'=>function ($model, $key, $index, $widget) { return "<span class='badge' style='background-color: {$model->color}'> </span> <code>" . $model->color . '</code>'; }, 'filterType'=>GridView::FILTER_COLOR, 'vAlign'=>'middle', 'format'=>'raw', 'width'=>'150px', 'noWrap'=>true ], [ 'class'=>'kartik\grid\BooleanColumn', 'attribute'=>'status', 'vAlign'=>'middle', ], [ 'class' => 'kartik\grid\ActionColumn', 'dropdown' => true, 'vAlign'=>'middle', 'urlCreator' => function($action, $model, $key, $index) { return '#'; }, 'viewOptions'=>['title'=>$viewMsg, 'data-toggle'=>'tooltip'], 'updateOptions'=>['title'=>$updateMsg, 'data-toggle'=>'tooltip'], 'deleteOptions'=>['title'=>$deleteMsg, 'data-toggle'=>'tooltip'], ], ['class' => 'kartik\grid\CheckboxColumn'] ]; echo GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumns, 'containerOptions' => ['style'=>'overflow: auto'], // only set when $responsive = false 'beforeHeader'=>[ [ 'columns'=>[ ['content'=>'Header Before 1', 'options'=>['colspan'=>4, 'class'=>'text-center warning']], ['content'=>'Header Before 2', 'options'=>['colspan'=>4, 'class'=>'text-center warning']], ['content'=>'Header Before 3', 'options'=>['colspan'=>3, 'class'=>'text-center warning']], ], 'options'=>['class'=>'skip-export'] // remove this row from export ] ], 'toolbar' => [ ['content'=> Html::button('<i class="glyphicon glyphicon-plus"></i>', ['type'=>'button', 'title'=>Yii::t('kvgrid', 'Add Book'), 'class'=>'btn btn-success', 'onclick'=>'alert("This will launch the book creation form.\n\nDisabled for this demo!");']) . ' '. Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['grid-demo'], ['data-pjax'=>0, 'class' => 'btn btn-default', 'title'=>Yii::t('kvgrid', 'Reset Grid')]) ], '{export}', '{toggleData}' ], 'pjax' => true, 'bordered' => true, 'striped' => false, 'condensed' => false, 'responsive' => true, 'hover' => true, 'floatHeader' => true, 'floatHeaderOptions' => ['top' => $scrollingTop], 'showPageSummary' => true, 'panel' => [ 'type' => GridView::TYPE_PRIMARY ], ]);
Contributors
Code Contributors
This project exists thanks to all the people who contribute. [Contribute]
Financial Contributors
Become a financial contributor and help us sustain our community. [Contribute]
Individuals
Organizations
Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]
License
yii2-grid is released under the BSD-3-Clause License. See the bundled LICENSE.md
for details.