Allow models to pass data source values to the DataGrid widget
This commit is contained in:
parent
4fa00f1c7b
commit
23fd094c8e
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue