Allow passing of columns to ColumnSelectionField() and allow different ColumnSelectionField() values to influence the result columsn

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@66626 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-11-25 07:24:40 +00:00
parent b1218f85da
commit 856e01b156

View File

@ -434,11 +434,13 @@ class ModelAdmin_CollectionController extends Controller {
/** /**
* Give the flexibilility to show variouse combination of columns in the search result table * Give the flexibilility to show variouse combination of columns in the search result table
* @param $columnsAvailable array The columns that should be made available for selecting. Should be a map. Keys are dot-syntax
* field names, and values are titles. By default the $summary_fields from your model will be used.
*/ */
public function ColumnSelectionField() { public function ColumnSelectionField($columnsAvailable = null) {
$model = singleton($this->modelClass); $model = singleton($this->modelClass);
$source = $model->summaryFields(); $source = $columnsAvailable ? $columnsAvailable : $model->summaryFields();
// select all fields by default // select all fields by default
$value = array(); $value = array();
@ -548,6 +550,8 @@ class ModelAdmin_CollectionController extends Controller {
$model = singleton($this->modelClass); $model = singleton($this->modelClass);
$summaryFields = $model->summaryFields(); $summaryFields = $model->summaryFields();
$summaryFields = $this->ColumnSelectionField()->Children->dataFieldByName('ResultAssembly')->Source;
if($selectedOnly) { if($selectedOnly) {
$resultAssembly = $searchCriteria['ResultAssembly']; $resultAssembly = $searchCriteria['ResultAssembly'];
if(!is_array($resultAssembly)) { if(!is_array($resultAssembly)) {