mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API CHANGE Renamed GridFieldDefaultColumns to GridFieldDataColumns #6921
This commit is contained in:
parent
6d0b0d6788
commit
09d6fa7bb3
@ -32,7 +32,7 @@ This example creates exactly the same kind of grid as the previous example, but
|
|||||||
// Provide a header row with filter controls
|
// Provide a header row with filter controls
|
||||||
$config->addComponent(new GridFieldFilterHeader());
|
$config->addComponent(new GridFieldFilterHeader());
|
||||||
// Provide a default set of columns based on $summary_fields
|
// Provide a default set of columns based on $summary_fields
|
||||||
$config->addComponent(new GridFieldDefaultColumns());
|
$config->addComponent(new GridFieldDataColumns());
|
||||||
// Provide a header row with sort controls
|
// Provide a header row with sort controls
|
||||||
$config->addComponent(new GridFieldSortableHeader());
|
$config->addComponent(new GridFieldSortableHeader());
|
||||||
// Paginate results to 25 items per page, and show a footer with pagination controls
|
// Paginate results to 25 items per page, and show a footer with pagination controls
|
||||||
@ -44,7 +44,7 @@ If we wanted to make a simpler grid without pagination or filtering, we could do
|
|||||||
:::php
|
:::php
|
||||||
$config = GridFieldConfig::create();
|
$config = GridFieldConfig::create();
|
||||||
// Provide a default set of columns based on $summary_fields
|
// Provide a default set of columns based on $summary_fields
|
||||||
$config->addComponent(new GridFieldDefaultColumns());
|
$config->addComponent(new GridFieldDataColumns());
|
||||||
// Provide a header row with sort controls
|
// Provide a header row with sort controls
|
||||||
$config->addComponent(new GridFieldPaginator(25));
|
$config->addComponent(new GridFieldPaginator(25));
|
||||||
$field = new GridField("Members", "Members of this group", $this->group->Members(), $config);
|
$field = new GridField("Members", "Members of this group", $this->group->Members(), $config);
|
||||||
@ -57,11 +57,11 @@ A `GridFieldConfig` is made up of a new of `GridFieldComponent` objects, which a
|
|||||||
`GridFieldComponent` is a family of interfaces.
|
`GridFieldComponent` is a family of interfaces.
|
||||||
SilverStripe Framework comes with the following components that you can use out of the box.
|
SilverStripe Framework comes with the following components that you can use out of the box.
|
||||||
|
|
||||||
### GridFieldDefaultColumns
|
### GridFieldDataColumns
|
||||||
|
|
||||||
This is the one component that, in most cases, you must include. It provides the default columns, sourcing them from the underlying DataObject's `$summary_fields` if no specific configuration is provided.
|
This is the one component that, in most cases, you must include. It provides the default columns, sourcing them from the underlying DataObject's `$summary_fields` if no specific configuration is provided.
|
||||||
|
|
||||||
Without GridFieldDefaultColumns added to a GridField, it would have no columns whatsoever. Although this isn't particularly useful most of the time, we have allowed for this for two reasons:
|
Without GridFieldDataColumns added to a GridField, it would have no columns whatsoever. Although this isn't particularly useful most of the time, we have allowed for this for two reasons:
|
||||||
|
|
||||||
* You may have a grid whose fields are generated purely by another non-standard component.
|
* You may have a grid whose fields are generated purely by another non-standard component.
|
||||||
* It keeps the core of the GridField lean, focused solely on providing APIs to the components.
|
* It keeps the core of the GridField lean, focused solely on providing APIs to the components.
|
||||||
@ -233,7 +233,7 @@ By default, a grid contains no columns. All the columns displayed in a grid wil
|
|||||||
|
|
||||||
For example, you may create a grid field with several components providing columns:
|
For example, you may create a grid field with several components providing columns:
|
||||||
|
|
||||||
* `GridFieldDefaultColumns` could provide basic data columns.
|
* `GridFieldDataColumns` could provide basic data columns.
|
||||||
* An editor component could provide a column containing action buttons on the right.
|
* An editor component could provide a column containing action buttons on the right.
|
||||||
* A multiselect component clould provide a column showing a checkbox on the left.
|
* A multiselect component clould provide a column showing a checkbox on the left.
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ class HtmlEditorField_Toolbar extends RequestHandler {
|
|||||||
$fileFieldConfig = GridFieldConfig::create();
|
$fileFieldConfig = GridFieldConfig::create();
|
||||||
$fileFieldConfig->addComponent(new GridFieldSortableHeader());
|
$fileFieldConfig->addComponent(new GridFieldSortableHeader());
|
||||||
$fileFieldConfig->addComponent(new GridFieldFilterHeader());
|
$fileFieldConfig->addComponent(new GridFieldFilterHeader());
|
||||||
$fileFieldConfig->addComponent(new GridFieldDefaultColumns());
|
$fileFieldConfig->addComponent(new GridFieldDataColumns());
|
||||||
$fileFieldConfig->addComponent(new GridFieldPaginator(5));
|
$fileFieldConfig->addComponent(new GridFieldPaginator(5));
|
||||||
$fileField = new GridField('Files', false, null, $fileFieldConfig);
|
$fileField = new GridField('Files', false, null, $fileFieldConfig);
|
||||||
$fileField->setList($this->getFiles($parentID));
|
$fileField->setList($this->getFiles($parentID));
|
||||||
|
@ -847,7 +847,7 @@ class UploadField_SelectHandler extends RequestHandler {
|
|||||||
$config = GridFieldConfig::create();
|
$config = GridFieldConfig::create();
|
||||||
$config->addComponent(new GridFieldSortableHeader());
|
$config->addComponent(new GridFieldSortableHeader());
|
||||||
$config->addComponent(new GridFieldFilterHeader());
|
$config->addComponent(new GridFieldFilterHeader());
|
||||||
$config->addComponent(new GridFieldDefaultColumns());
|
$config->addComponent(new GridFieldDataColumns());
|
||||||
$config->addComponent(new GridFieldPaginator(10));
|
$config->addComponent(new GridFieldPaginator(10));
|
||||||
|
|
||||||
$field = new GridField('Files', false, $folder->stageChildren(), $config);
|
$field = new GridField('Files', false, $folder->stageChildren(), $config);
|
||||||
|
@ -404,7 +404,7 @@ class GridField extends FormField {
|
|||||||
array(
|
array(
|
||||||
"class" => implode(' ', $classes),
|
"class" => implode(' ', $classes),
|
||||||
'data-id' => $record->ID,
|
'data-id' => $record->ID,
|
||||||
// TODO Allow per-row customization similar to GridFieldDefaultColumns
|
// TODO Allow per-row customization similar to GridFieldDataColumns
|
||||||
'data-class' => $record->ClassName,
|
'data-class' => $record->ClassName,
|
||||||
),
|
),
|
||||||
$rowContent
|
$rowContent
|
||||||
|
@ -36,7 +36,7 @@ interface GridField_ColumnProvider extends GridFieldComponent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Modify the list of columns displayed in the table.
|
* Modify the list of columns displayed in the table.
|
||||||
* See {@link GridField->getDisplayFields()} and {@link GridFieldDefaultColumns}.
|
* See {@link GridField->getDisplayFields()} and {@link GridFieldDataColumns}.
|
||||||
*
|
*
|
||||||
* @param GridField
|
* @param GridField
|
||||||
* @param Array List reference of all column names.
|
* @param Array List reference of all column names.
|
||||||
|
@ -134,7 +134,7 @@ class GridFieldConfig_Base extends GridFieldConfig {
|
|||||||
$this->addComponent(new GridFieldToolbarHeader());
|
$this->addComponent(new GridFieldToolbarHeader());
|
||||||
$this->addComponent(new GridFieldSortableHeader());
|
$this->addComponent(new GridFieldSortableHeader());
|
||||||
$this->addComponent(new GridFieldFilterHeader());
|
$this->addComponent(new GridFieldFilterHeader());
|
||||||
$this->addComponent(new GridFieldDefaultColumns());
|
$this->addComponent(new GridFieldDataColumns());
|
||||||
$this->addComponent(new GridFieldPaginator($itemsPerPage));
|
$this->addComponent(new GridFieldPaginator($itemsPerPage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ class GridFieldConfig_RecordEditor extends GridFieldConfig {
|
|||||||
$this->addComponent(new GridFieldToolbarHeader());
|
$this->addComponent(new GridFieldToolbarHeader());
|
||||||
$this->addComponent(new GridFieldSortableHeader());
|
$this->addComponent(new GridFieldSortableHeader());
|
||||||
$this->addComponent(new GridFieldFilterHeader());
|
$this->addComponent(new GridFieldFilterHeader());
|
||||||
$this->addComponent(new GridFieldDefaultColumns());
|
$this->addComponent(new GridFieldDataColumns());
|
||||||
$this->addComponent(new GridFieldEditButton());
|
$this->addComponent(new GridFieldEditButton());
|
||||||
$this->addComponent(new GridFieldDeleteAction());
|
$this->addComponent(new GridFieldDeleteAction());
|
||||||
$this->addComponent(new GridFieldPaginator($itemsPerPage));
|
$this->addComponent(new GridFieldPaginator($itemsPerPage));
|
||||||
@ -204,7 +204,7 @@ class GridFieldConfig_RelationEditor extends GridFieldConfig {
|
|||||||
$this->addComponent(new GridFieldAddExistingAutocompleter());
|
$this->addComponent(new GridFieldAddExistingAutocompleter());
|
||||||
$this->addComponent(new GridFieldSortableHeader());
|
$this->addComponent(new GridFieldSortableHeader());
|
||||||
$this->addComponent(new GridFieldFilterHeader());
|
$this->addComponent(new GridFieldFilterHeader());
|
||||||
$this->addComponent(new GridFieldDefaultColumns());
|
$this->addComponent(new GridFieldDataColumns());
|
||||||
$this->addComponent(new GridFieldEditButton());
|
$this->addComponent(new GridFieldEditButton());
|
||||||
$this->addComponent(new GridFieldDeleteAction(true));
|
$this->addComponent(new GridFieldDeleteAction(true));
|
||||||
$this->addComponent(new GridFieldPaginator($itemsPerPage));
|
$this->addComponent(new GridFieldPaginator($itemsPerPage));
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* @package sapphire
|
* @package sapphire
|
||||||
* @subpackage fields-relational
|
* @subpackage fields-relational
|
||||||
*/
|
*/
|
||||||
class GridFieldDefaultColumns implements GridField_ColumnProvider {
|
class GridFieldDataColumns implements GridField_ColumnProvider {
|
||||||
|
|
||||||
public function augmentColumns($gridField, &$columns) {
|
public function augmentColumns($gridField, &$columns) {
|
||||||
$baseColumns = array_keys($gridField->getDisplayFields());
|
$baseColumns = array_keys($gridField->getDisplayFields());
|
@ -32,7 +32,7 @@ class GridFieldTest extends SapphireTest {
|
|||||||
new GridFieldToolbarHeader(),
|
new GridFieldToolbarHeader(),
|
||||||
new GridFieldSortableHeader,
|
new GridFieldSortableHeader,
|
||||||
new GridFieldFilterHeader,
|
new GridFieldFilterHeader,
|
||||||
new GridFieldDefaultColumns,
|
new GridFieldDataColumns,
|
||||||
new GridFieldPaginator,
|
new GridFieldPaginator,
|
||||||
new GridState_Component,
|
new GridState_Component,
|
||||||
));
|
));
|
||||||
@ -48,13 +48,13 @@ class GridFieldTest extends SapphireTest {
|
|||||||
|
|
||||||
$config = GridFieldConfig::create();
|
$config = GridFieldConfig::create();
|
||||||
$config->addComponent(new GridFieldSortableHeader());
|
$config->addComponent(new GridFieldSortableHeader());
|
||||||
$config->addComponent(new GridFieldDefaultColumns());
|
$config->addComponent(new GridFieldDataColumns());
|
||||||
|
|
||||||
$obj = new GridField('testfield', 'testfield', ArrayList::create(array()),$config);
|
$obj = new GridField('testfield', 'testfield', ArrayList::create(array()),$config);
|
||||||
|
|
||||||
$expectedComponents = new ArrayList(array(
|
$expectedComponents = new ArrayList(array(
|
||||||
0 => new GridFieldSortableHeader,
|
0 => new GridFieldSortableHeader,
|
||||||
1 => new GridFieldDefaultColumns,
|
1 => new GridFieldDataColumns,
|
||||||
2 => new GridState_Component,
|
2 => new GridState_Component,
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -430,7 +430,7 @@ class GridFieldTest extends SapphireTest {
|
|||||||
));
|
));
|
||||||
|
|
||||||
$config = new GridFieldConfig();
|
$config = new GridFieldConfig();
|
||||||
$config->addComponent(new GridFieldDefaultColumns());
|
$config->addComponent(new GridFieldDataColumns());
|
||||||
$obj = new GridField('testfield', 'testfield', $list, $config);
|
$obj = new GridField('testfield', 'testfield', $list, $config);
|
||||||
$form = new Form(new Controller(), 'mockform', new FieldList(array($obj)), new FieldList());
|
$form = new Form(new Controller(), 'mockform', new FieldList(array($obj)), new FieldList());
|
||||||
$content = new CSSContentParser($obj->FieldHolder());
|
$content = new CSSContentParser($obj->FieldHolder());
|
||||||
|
@ -75,7 +75,7 @@ class GridFieldAddExistingAutocompleterTest_Controller extends Controller implem
|
|||||||
$player = DataObject::get('GridFieldTest_Player')->find('Email', 'player1@test.com');
|
$player = DataObject::get('GridFieldTest_Player')->find('Email', 'player1@test.com');
|
||||||
$config = GridFieldConfig::create()->addComponents(
|
$config = GridFieldConfig::create()->addComponents(
|
||||||
$relationComponent = new GridFieldAddExistingAutocompleter('Name'),
|
$relationComponent = new GridFieldAddExistingAutocompleter('Name'),
|
||||||
new GridFieldDefaultColumns()
|
new GridFieldDataColumns()
|
||||||
);
|
);
|
||||||
$field = new GridField('testfield', 'testfield', $player->Teams(), $config);
|
$field = new GridField('testfield', 'testfield', $player->Teams(), $config);
|
||||||
return new Form($this, 'Form', new FieldList($field), new FieldList());
|
return new Form($this, 'Form', new FieldList($field), new FieldList());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user