diff --git a/src/DataSources/MergedDataSource.php b/src/DataSources/MergedDataSource.php index 26445ca..5eebcdf 100644 --- a/src/DataSources/MergedDataSource.php +++ b/src/DataSources/MergedDataSource.php @@ -34,9 +34,16 @@ public function getRowId($row) if (is_array($row)) { throw new \Inteve\DataGrid\InvalidArgumentException(self::class . ' requires only objects, array given.'); } + $class = get_class($row); if (!isset($this->dataSources[$class])) { + foreach ($this->dataSources as $dataSourceClass => $dataSource) { + if ($row instanceof $dataSourceClass) { + return $dataSource->getRowId($row); + } + } + throw new \Inteve\DataGrid\InvalidArgumentException('Unknow row type, there is no data source for it.'); }