Allow models to pass data source values to the DataGrid widget

This commit is contained in:
flynsarmy 2014-07-30 16:17:03 +10:00
parent 4fa00f1c7b
commit 23fd094c8e
1 changed files with 13 additions and 1 deletions

View File

@ -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;
}
}
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;
}
}