PHP Class Grid_Advanced, atk4

Inheritance: extends Grid_Basic
Mostrar archivo Open project: atk4/atk4 Class Usage Examples

Public Properties

Property Type Description
$_url
$data Static data source?
$js_widget JavaScript widget
$js_widget_arguments
$paginator Paginator Paginator object.
$paginator_class string Paginator class name.
$quick_search QuickSearch QuickSearch object.
$quick_search_class string QuickSearch class name.
$sortby Sorting
$sortby_db

Protected Properties

Property Type Description
$tdparam array This should be a hash: 'param_name'=>'param_value' Following parameters treated and processed in a special way: 1) 'style': nested array, style parameter. items of this nested array converted to a form of style: style="param_name: param_value; param_name: param_value". All the rest are not checked and simply converted to a form of param_name="param_value" This is a tree-like array with the following structure: array( [level1] => dataset_row = array( [level2] => field = array( [level3] => tdparam_elements = array( param_name => param_value ) ) ) )

Public Methods

Method Description
_performDelete ( string $id ) Delete record from DB.
addOrder ( ) : Order Adds column ordering object.
addPaginator ( integer $rows = 25, array $options = null, string $class = null ) : Paginator Adds paginator to the grid.
addQuickSearch ( array $fields, array $options = null, string $class = null, string $spot = null ) : QuickSearch Adds QuickSearch to the grid.
addSelectable ( mixed $field ) Adds column with checkboxes on the basis of Model definition.
applySorting ( Iterator $i, string $field, string | boolean $desc ) Apply sorting on particular field.
applyTDParams ( string $field, SQLite &$row_template = null ) Apply TD parameters to appropriate template.
enablePaginator ( integer $rows = 25, array $options = null ) Add default paginator to the grid.
enableQuickSearch ( array $fields, array $options = null ) Adds default QuickSearch to the grid.
formatTotalsRow ( ) Additional formatting for Totals row.
format_boolean ( string $field ) Format field as boolean.
format_button ( string $field ) Format field as button.
format_checkbox ( string $field ) Format field as checkbox.
format_confirm ( string $field ) Format field as confirm button.
format_date ( string $field ) Format field as date.
format_datetime ( string $field ) Format field as datetime.
format_delete ( string $field ) Format field as delete button.
format_expander ( string $field, array $column ) Format expander.
format_float ( string $field ) Format field as real number with 2 digit precision.
format_fullwidth ( string $field ) Format field as full width field.
format_html ( string $field ) Format field as HTML without encoding. Use with care.
format_image ( string $field ) Format field as HTML image tag.
format_link ( string $field ) Format field as link.
format_money ( string $field ) Format field as money with 2 digit precision.
format_nl2br ( string $field ) Format field as New-Line to BR-eak.
format_nowrap ( string $field ) Format field as no-wrap field.
format_number ( string $field ) Format field as number.
format_object ( string $field ) Format field as object.
format_password ( string $field ) Format password field.
format_prompt ( string $field ) Format field as prompt button.
format_real ( $field )
format_shorttext ( string $field ) Format shorttext field.
format_template ( string $field ) Format field using template.
format_time ( string $field ) Format field as time.
format_timestamp ( string $field ) Format field as timestamp.
format_totals_checkbox ( string $field, array $column ) Additional formatting of checkbox fields column for totals row.
format_totals_delete ( string $field, array $column ) Additional formatting of delete button fields for totals row.
format_totals_expander ( string $field, array $column ) Additional formatting of expander fields for totals row.
format_totals_money ( string $field ) Additional formatting of money fields for totals row.
format_totals_number ( string $field ) Additional formatting of number fields for totals row.
format_totals_real ( string $field ) Additional formatting of real number fields for totals row.
format_totals_template ( string $field, array $column ) Additional formatting of custom template fields for totals row.
format_wrap ( string $field ) Format field as wrap field.
getCurrentIndex ( string $idfield = 'id' ) : mixed Returns ID of record.
getIterator ( ) : mixed Returns data source iterator.
init ( ) Initialization.
init_boolean ( string $field ) Initialize column as boolean.
init_button ( string $field ) Initialize buttons column.
init_confirm ( string $field ) Initialize confirm buttons column.
init_delete ( string $field ) Initialize column with delete buttons.
init_expander ( string $field ) Initialize expander.
init_float ( string $field ) Initialize column as real number.
init_fullwidth ( string $field ) Initialize column as fullwidth.
init_link ( string $field ) Initialize column with links using template.
init_money ( string $field ) Initialize column as money.
init_prompt ( string $field ) Initialize prompt buttons column.
init_real ( $field )
makeSortable ( string $db_sort = null ) Make sortable.
render ( ) Render grid.
renderTotalsRow ( ) Render Totals row.
setTDParam ( string $field, string $path, string $value ) Sets TD params.
setTemplate ( string $template, $field = null ) This allows you to use Template.
setTotalsTitle ( string $field, string $title = 'Total: %s row%s' ) Sets totals title field and text.
staticSortCompare ( string $str1, string $str2 ) : integer Compare two strings and return: < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.
updateGrandTotals ( ) Calculate grand totals of all rows.
updateTotals ( ) Add current rendered row values to totals.

Method Details

_performDelete() public method

Formatter init_delete() calls this to delete current record from DB
public _performDelete ( string $id )
$id string ID of record

addOrder() public method

With it you can reorder your columns
public addOrder ( ) : Order
return Order

addPaginator() public method

Adds paginator to the grid.
public addPaginator ( integer $rows = 25, array $options = null, string $class = null ) : Paginator
$rows integer row count per page
$options array optional options array
$class string optional paginator class name
return Paginator

addQuickSearch() public method

Adds QuickSearch to the grid.
public addQuickSearch ( array $fields, array $options = null, string $class = null, string $spot = null ) : QuickSearch
$fields array array of fieldnames used in quick search
$options array optional options array
$class string optional quick search object class
$spot string optional template spot
return QuickSearch

addSelectable() public method

Adds column with checkboxes on the basis of Model definition.
public addSelectable ( mixed $field )
$field mixed should be Form_Field object or jQuery selector of 1 field. When passing it as jQuery selector don't forget to use hash sign like "#myfield"

applySorting() public method

Apply sorting on particular field.
public applySorting ( Iterator $i, string $field, string | boolean $desc )
$i Iterator
$field string
$desc string | boolean

applyTDParams() public method

You can pass row template to use too. That's useful to set up totals rows, for example.
public applyTDParams ( string $field, SQLite &$row_template = null )
$field string Fieldname
$row_template SQLite Optional row template

enablePaginator() public method

Add default paginator to the grid.
public enablePaginator ( integer $rows = 25, array $options = null )
$rows integer row count per page
$options array optional options array

enableQuickSearch() public method

Adds default QuickSearch to the grid.
public enableQuickSearch ( array $fields, array $options = null )
$fields array array of fieldnames used in quick search
$options array optional options array

formatTotalsRow() public method

Extends CompleteLister formatTotalsRow method. Note: in this method you should only add *additional* formatting of totals row because standard row formatting will be already applied by calling parent::formatTotalsRow().
public formatTotalsRow ( )

format_boolean() public method

Format field as boolean.
public format_boolean ( string $field )
$field string

format_button() public method

Format field as button.
public format_button ( string $field )
$field string

format_checkbox() public method

Format field as checkbox.
public format_checkbox ( string $field )
$field string

format_confirm() public method

Format field as confirm button.
public format_confirm ( string $field )
$field string

format_date() public method

Format field as date.
public format_date ( string $field )
$field string

format_datetime() public method

Format field as datetime.
public format_datetime ( string $field )
$field string

format_delete() public method

Format field as delete button.
public format_delete ( string $field )
$field string

format_expander() public method

Format expander.
public format_expander ( string $field, array $column )
$field string field name
$column array column configuration

format_float() public method

Format field as real number with 2 digit precision.
public format_float ( string $field )
$field string

format_fullwidth() public method

Format field as full width field.
public format_fullwidth ( string $field )
$field string

format_html() public method

Format field as HTML without encoding. Use with care.
public format_html ( string $field )
$field string

format_image() public method

Format field as HTML image tag.
public format_image ( string $field )
$field string

format_money() public method

Format field as money with 2 digit precision.
public format_money ( string $field )
$field string

format_nl2br() public method

Format field as New-Line to BR-eak.
public format_nl2br ( string $field )
$field string

format_nowrap() public method

Format field as no-wrap field.
public format_nowrap ( string $field )
$field string

format_number() public method

Format field as number.
public format_number ( string $field )
$field string

format_object() public method

Format field as object.
public format_object ( string $field )
$field string

format_password() public method

Format password field.
public format_password ( string $field )
$field string

format_prompt() public method

Format field as prompt button.
public format_prompt ( string $field )
$field string

format_real() public method

public format_real ( $field )

format_shorttext() public method

Format shorttext field.
public format_shorttext ( string $field )
$field string

format_template() public method

Format field using template.
public format_template ( string $field )
$field string

format_time() public method

Format field as time.
public format_time ( string $field )
$field string

format_timestamp() public method

Format field as timestamp.
public format_timestamp ( string $field )
$field string

format_totals_checkbox() public method

Basically we remove everything from such field
public format_totals_checkbox ( string $field, array $column )
$field string field name
$column array column configuration

format_totals_delete() public method

Basically we remove everything from such field
public format_totals_delete ( string $field, array $column )
$field string field name
$column array column configuration

format_totals_expander() public method

Basically we remove everything from such field
public format_totals_expander ( string $field, array $column )
$field string field name
$column array column configuration

format_totals_money() public method

Additional formatting of money fields for totals row.
public format_totals_money ( string $field )
$field string

format_totals_number() public method

Additional formatting of number fields for totals row.
public format_totals_number ( string $field )
$field string

format_totals_real() public method

Additional formatting of real number fields for totals row.
public format_totals_real ( string $field )
$field string

format_totals_template() public method

Basically we remove everything from such field
public format_totals_template ( string $field, array $column )
$field string field name
$column array column configuration

format_wrap() public method

Format field as wrap field.
public format_wrap ( string $field )
$field string

getCurrentIndex() public method

Returns ID of record.
public getCurrentIndex ( string $idfield = 'id' ) : mixed
$idfield string ID field name
return mixed

getIterator() public method

Returns data source iterator.
public getIterator ( ) : mixed
return mixed

init() public method

Initialization.
public init ( )

init_boolean() public method

Initialize column as boolean.
public init_boolean ( string $field )
$field string

init_button() public method

Initialize buttons column.
public init_button ( string $field )
$field string

init_confirm() public method

Initialize confirm buttons column.
public init_confirm ( string $field )
$field string

init_delete() public method

Initialize column with delete buttons.
public init_delete ( string $field )
$field string

init_expander() public method

Initialize expander.
public init_expander ( string $field )
$field string field name

init_float() public method

Initialize column as real number.
public init_float ( string $field )
$field string

init_fullwidth() public method

Initialize column as fullwidth.
public init_fullwidth ( string $field )
$field string

init_money() public method

Initialize column as money.
public init_money ( string $field )
$field string

init_prompt() public method

Initialize prompt buttons column.
public init_prompt ( string $field )
$field string

init_real() public method

public init_real ( $field )

makeSortable() public method

Make sortable.
public makeSortable ( string $db_sort = null )
$db_sort string

render() public method

Render grid.
public render ( )

renderTotalsRow() public method

Render Totals row.
public renderTotalsRow ( )

setTDParam() public method

Sets TD params.
public setTDParam ( string $field, string $path, string $value )
$field string
$path string
$value string

setTemplate() public method

This allows you to use Template.
public setTemplate ( string $template, $field = null )
$template string template as a string

setTotalsTitle() public method

Sets totals title field and text.
public setTotalsTitle ( string $field, string $title = 'Total: %s row%s' )
$field string
$title string

staticSortCompare() public method

Note that this comparison is case sensitive
public staticSortCompare ( string $str1, string $str2 ) : integer
$str1 string
$str2 string
return integer

updateGrandTotals() public method

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

updateTotals() public method

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

Property Details

$_url public_oe property

public $_url

$data public_oe property

Static data source?
public $data

$js_widget public_oe property

JavaScript widget
public $js_widget

$js_widget_arguments public_oe property

public $js_widget_arguments

$paginator public_oe property

Paginator object.
See also: addPaginator()
public Paginator $paginator
return Paginator

$paginator_class public_oe property

Paginator class name.
See also: enablePaginator()
public string $paginator_class
return string

$quick_search_class public_oe property

QuickSearch class name.
See also: enableQuickSearch()
public string $quick_search_class
return string

$sortby public_oe property

Sorting
public $sortby

$sortby_db public_oe property

public $sortby_db

$tdparam protected_oe property

This should be a hash: 'param_name'=>'param_value' Following parameters treated and processed in a special way: 1) 'style': nested array, style parameter. items of this nested array converted to a form of style: style="param_name: param_value; param_name: param_value". All the rest are not checked and simply converted to a form of param_name="param_value" This is a tree-like array with the following structure: array( [level1] => dataset_row = array( [level2] => field = array( [level3] => tdparam_elements = array( param_name => param_value ) ) ) )
protected array $tdparam
return array