PHP Класс CompleteLister, atk4

Also adds support for calculating totals. Use: $list = $this->add('CompleteLister'); $list->setModel('User'); $list->addTotals(); Template (view/users.html):

Users

Joe Blogs

Sample template. Will be ignored

user.
Наследование: extends Lister
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$even_css_class Used CSS class for even rows
$odd_css_class Used CSS class for odd rows
$row_t Item ($item_tag) template
$sep_html Separator
$total_rows integer After rendering will contain data row count
$totals array | boolean Will contain accumulated totals for all fields
$totals_t Template Will be initialized to "totals" template when _addTotals() is called

Защищенные свойства (Protected)

Свойство Тип Описание
$container_tag Template tag for container
$item_tag Template tag for item
$odd_even Is current odd or even row?
$totals_type string Should be changed using addTotals and addGrandTotals methods only

Открытые методы

Метод Описание
addGrandTotals ( array $fields = UNDEFINED ) Enable totals calculation for specified array of fields.
addTotals ( array $fields = UNDEFINED ) Enable totals calculation for specified array of fields.
defaultTemplate ( ) : array Default template.
formatRow ( ) Format lister row.
formatTotalsRow ( ) Additional formatting for Totals row.
init ( ) Initialization.
removeTotals ( ) Disable totals calculation.
render ( ) Render lister.
renderDataRow ( ) Render data row.
renderRows ( ) Render lister rows.
renderSeparator ( )
renderTotalsRow ( ) Render Totals row.
updateGrandTotals ( ) Calculate grand totals of all rows.
updateTotals ( ) Add current rendered row values to totals.

Защищенные методы

Метод Описание
_addTotals ( array $fields = UNDEFINED, string $type = null ) Private method to enable / disable totals calculation for specified array of fields.

Описание методов

_addTotals() защищенный Метод

If particular fields not specified, then all field totals are calculated. If you only need to count records, then pass null and no fields will be calculated.
protected _addTotals ( array $fields = UNDEFINED, string $type = null )
$fields array optional array of fieldnames
$type string type of totals calculation (null|onRender|onRequest)

addGrandTotals() публичный Метод

If particular fields not specified, then all field totals are calculated. If you only need to count records, then pass null and no fields will be calculated. Be aware that this method works ONLY for SQL models set as data source because this calculates grand totals using DSQL.
public addGrandTotals ( array $fields = UNDEFINED )
$fields array optional array of fieldnames

addTotals() публичный Метод

If particular fields not specified, then all field totals are calculated. If you only need to count records, then pass null and no fields will be calculated. Be aware that if you use Paginator, then only records of current page will be calculated. If you need grand totals for all records, then use method addGrandTotals() instead.
public addTotals ( array $fields = UNDEFINED )
$fields array optional array of fieldnames

defaultTemplate() публичный Метод

Default template.
public defaultTemplate ( ) : array
Результат array

formatRow() публичный Метод

Format lister row.
public formatRow ( )

formatTotalsRow() публичный Метод

Additional formatting for Totals row.
public formatTotalsRow ( )

init() публичный Метод

Initialization.
public init ( )

removeTotals() публичный Метод

Disable totals calculation.
public removeTotals ( )

render() публичный Метод

Render lister.
public render ( )

renderDataRow() публичный Метод

Render data row.
public renderDataRow ( )

renderRows() публичный Метод

Render lister rows.
public renderRows ( )

renderSeparator() публичный Метод

public renderSeparator ( )

renderTotalsRow() публичный Метод

Render Totals row.
public renderTotalsRow ( )

updateGrandTotals() публичный Метод

Called one time on rendering phase - before renderRows() call.
public updateGrandTotals ( )

updateTotals() публичный Метод

Called before each formatRow() call.
public updateTotals ( )

Описание свойств

$container_tag защищенное свойство

Template tag for container
protected $container_tag

$even_css_class публичное свойство

Used CSS class for even rows
public $even_css_class

$item_tag защищенное свойство

Template tag for item
protected $item_tag

$odd_css_class публичное свойство

Used CSS class for odd rows
public $odd_css_class

$odd_even защищенное свойство

Is current odd or even row?
protected $odd_even

$row_t публичное свойство

Item ($item_tag) template
public $row_t

$sep_html публичное свойство

Separator
public $sep_html

$total_rows публичное свойство

After rendering will contain data row count
public int $total_rows
Результат integer

$totals публичное свойство

Will contain accumulated totals for all fields
public array|bool $totals
Результат array | boolean

$totals_t публичное свойство

Will be initialized to "totals" template when _addTotals() is called
public Template $totals_t
Результат Template

$totals_type защищенное свойство

Should be changed using addTotals and addGrandTotals methods only
protected string $totals_type
Результат string