kl83 / yii2-grid-sortable-column
Sortable column for Yii2 GridView
Installs: 8 212
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.4.0
- yiisoft/yii2: ^2.0.0
- yiisoft/yii2-bootstrap: ~2.0.0
- yiisoft/yii2-jui: ~2.0.0
This package is auto-updated.
Last update: 2024-10-29 04:53:21 UTC
README
The GridView column class for sorting rows. Looks like this:
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require kl83/yii2-grid-sortable-column ~1.0.0
or add
"kl83/yii2-grid-sortable-column": "~1.0.0"
to the require section of your composer.json file.
Usage
Add column
<?= GridView::widget([ 'id' => 'gridview', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ [ 'class' => 'kl83\grid\SortableColumn' ], 'title', 'type', [ 'class' => 'yii\grid\ActionColumn' ], ], ]); ?>
Listen GridView event
$this->registerJs(" $('#gridview').bind('sortablecolumn-sort', function ( e, data ) { // Sending data to the server $.get('/move-row', { itemId: data.itemId, // The key of the dragged row prevId: data.prevId, // The key of the previous row, false if the row is the first nextId: data.nextId // The key of the next row, false if the row is the last }); }); ");
License
MIT License