From 23fd094c8e9861dd4b027b8075fdd943f7c82eb4 Mon Sep 17 00:00:00 2001 From: flynsarmy Date: Wed, 30 Jul 2014 16:17:03 +1000 Subject: [PATCH] Allow models to pass data source values to the DataGrid widget --- modules/backend/formwidgets/DataGrid.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/backend/formwidgets/DataGrid.php b/modules/backend/formwidgets/DataGrid.php index 1b405ca8c..e1628c6ef 100644 --- a/modules/backend/formwidgets/DataGrid.php +++ b/modules/backend/formwidgets/DataGrid.php @@ -74,6 +74,7 @@ class DataGrid extends FormWidgetBase $grid = new Grid($this->controller, $config); $grid->alias = $this->alias . 'Grid'; $grid->bindEvent('grid.autocomplete', [$this, 'getAutocompleteValues']); + $grid->bindEvent('grid.dataSource', [$this, 'getDataSourceValues']); return $grid; } @@ -89,4 +90,15 @@ class DataGrid extends FormWidgetBase return $result; } -} \ No newline at end of file + + + public function getDataSourceValues() + { + if (!$this->model->methodExists('getGridDataSourceValues')) + throw new ApplicationException('Model :model does not contain a method getGridDataSourceValues()'); + + $result = $this->model->getGridDataSourceValues(); + + return $result; + } +}