Skip to content
This repository has been archived by the owner on Oct 8, 2023. It is now read-only.

Commit

Permalink
Fix sort keys after custom sort all models
Browse files Browse the repository at this point in the history
  • Loading branch information
lav45 committed Jun 14, 2016
1 parent 0d0703e commit ecf91ad
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions TreeGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Yii;
use yii\base\InvalidConfigException;
use yii\base\Widget;
use yii\db\ActiveQueryInterface;
use yii\grid\DataColumn;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
Expand Down Expand Up @@ -293,10 +294,13 @@ public function renderTableFooter()
public function renderItems()
{
$rows = [];
$this->dataProvider->setKeys([]);
$models = array_values($this->dataProvider->getModels());
$models = $this->normalizeData($models, $this->parentRootValue);
$keys = ArrayHelper::getColumn($models, $this->keyColumnName);

$this->dataProvider->setModels($models);
$this->dataProvider->setKeys(null);
$this->dataProvider->prepare();
$keys = $this->dataProvider->getKeys();
foreach ($models as $index => $model) {
$key = $keys[$index];
if ($this->beforeRow !== null) {
Expand Down

0 comments on commit ecf91ad

Please sign in to comment.