Skip to content

Commit a4a7ba5

Browse files
committed
add afterGridSort method in SortableGridBehavior
1 parent 5a1465e commit a4a7ba5

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

SortableGridAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @link https://github.com/himiklab/yii2-sortable-grid-view-widget
4-
* @copyright Copyright (c) 2014 HimikLab
4+
* @copyright Copyright (c) 2014-2017 HimikLab
55
* @license http://opensource.org/licenses/MIT MIT
66
*/
77

SortableGridAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @link https://github.com/himiklab/yii2-sortable-grid-view-widget
4-
* @copyright Copyright (c) 2014 HimikLab
4+
* @copyright Copyright (c) 2014-2017 HimikLab
55
* @license http://opensource.org/licenses/MIT MIT
66
*/
77

SortableGridBehavior.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @link https://github.com/himiklab/yii2-sortable-grid-view-widget
4-
* @copyright Copyright (c) 2014 HimikLab
4+
* @copyright Copyright (c) 2014-2017 HimikLab
55
* @license http://opensource.org/licenses/MIT MIT
66
*/
77

@@ -42,6 +42,9 @@ class SortableGridBehavior extends Behavior
4242
/** @var callable */
4343
public $scope;
4444

45+
/** @var callable */
46+
public $afterGridSort;
47+
4548
public function events()
4649
{
4750
return [ActiveRecord::EVENT_BEFORE_INSERT => 'beforeInsert'];
@@ -67,6 +70,10 @@ public function gridSort($items)
6770
$models[$modelId]->updateAttributes([$this->sortableAttribute => $orderValue]);
6871
}
6972
});
73+
74+
if (is_callable($this->afterGridSort)) {
75+
call_user_func($this->afterGridSort, $model);
76+
}
7077
}
7178

7279
public function beforeInsert()

SortableGridView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @link https://github.com/himiklab/yii2-sortable-grid-view-widget
4-
* @copyright Copyright (c) 2014 HimikLab
4+
* @copyright Copyright (c) 2014-2017 HimikLab
55
* @license http://opensource.org/licenses/MIT MIT
66
*/
77

0 commit comments

Comments
 (0)