Browse Source

RowSelector::titleColumn支持设置关联模型字段

jqh 5 years ago
parent
commit
c27faf502f
2 changed files with 3 additions and 2 deletions
  1. 1 1
      src/Grid/Column.php
  2. 2 1
      src/Grid/Tools/RowSelector.php

+ 1 - 1
src/Grid/Column.php

@@ -470,7 +470,7 @@ class Column
      */
     public function action($action)
     {
-        if (!is_subclass_of($action, RowAction::class)) {
+        if (! is_subclass_of($action, RowAction::class)) {
             throw new \InvalidArgumentException("Action class [$action] must be sub-class of [Dcat\Admin\Grid\RowAction]");
         }
 

+ 2 - 1
src/Grid/Tools/RowSelector.php

@@ -4,6 +4,7 @@ namespace Dcat\Admin\Grid\Tools;
 
 use Dcat\Admin\Admin;
 use Dcat\Admin\Grid;
+use Illuminate\Support\Arr;
 
 class RowSelector
 {
@@ -93,7 +94,7 @@ JS
     protected function getTitle($row, $id)
     {
         if ($key = $this->titleColumn) {
-            $label = $row->{$key};
+            $label = Arr::get($row->toArray(), $key);
             if ($label !== null && $label !== '') {
                 return $label;
             }