silverstripe-framework/forms/gridfield/GridFieldPageCount.php
Damian Mooyman f265595c1e NEW: GridFieldPageCount control for displaying the current page count/total in the gridview header. Designed to complement a functional pager in the grid footer.
NEW: GridFieldPageCount widget to default config settings
FIX: @extend .col_buttons in GridField.scss which was raising a warning
2012-10-03 14:54:37 +13:00

48 lines
1.1 KiB
PHP
Executable File

<?php
/**
* GridFieldPage displays a simple current page count summary.
* E.g. "View 1 - 15 of 32"
*
* Depends on GridFieldPaginator being added to the same gridfield
*
* @package framework
* @subpackage fields-relational
*/
class GridFieldPageCount implements GridField_HTMLProvider {
/**
* @var string placement indicator for this control
*/
protected $targetFragment;
/**
* Which template to use for rendering
*
* @var string
*/
protected $itemClass = 'GridFieldPageCount';
/**
* @param string $targetFrament The fragment indicating the placement of this page count
*/
public function __construct($targetFragment = 'before') {
$this->targetFragment = $targetFragment;
}
/**
* @param GridField $gridField
* @return array
*/
public function getHTMLFragments($gridField) {
// Retrieve paging parameters from the directing paginator component
$paginator = $gridField->getConfig()->getComponentByType('GridFieldPaginator');
if ($paginator && ($forTemplate = $paginator->getTemplateParameters($gridField))) {
return array(
$this->targetFragment => $forTemplate->renderWith($this->itemClass)
);
}
}
}