Skip to content

classes_lib_controls_listing_wdflisting.class

Daniel Spors edited this page Mar 11, 2024 · 3 revisions

Classes in file lib/controls/listing/wdflisting.class.php

class WdfListing

High level listing control. It represents a database table with paging, sorting and more features.

Implements: <>

Extends: Control » Renderable

addAction

SHORTCUT Table::AddRowAction

addColCallback

Adds a callback for column rendering.

Definition: public function addColCallback($colnames, $callback)

Returns: static

Parameters:

  • array|string $colnames Column name(s)

  • callable $callback Callback, signature: function($value, $row){ return 'rendered value'; }

addColClass

Adds a CSS class to columns.

Definition: public function addColClass($name, $class=false)

Returns: static

Parameters:

  • array|string $name Column name or array of column names and class-values.

  • mixed $class Optional Class-Value, if $name is a string.

addColumn

Adds a column to be rendered.

Definition: public function addColumn($name, $label, $format=false, $alignment)

Returns: static

Parameters:

  • mixed $name Column name. If this matches a databse column, those values will be rendered.

  • mixed $label Column label.

  • mixed $format Column format or callback with signature function($v,$row){ return 'rendered'; }.

  • mixed $alignment Column alignment.

addComplexColumn

Adds a column based on a subquery.

Definition: public function addComplexColumn($name, $label, $sql, $arguments, $format=false, $alignment)

Returns: static

Parameters:

  • mixed $name Column name.

  • mixed $label Colulmn label

  • mixed $sql SQL statement

  • mixed $arguments SQL arguments

  • mixed $format Column format or callback.

  • mixed $alignment Column alignment.

addField

Adds a column based on a subquery.

Definition: public function addField($sql, $arguments)

Returns: static

Parameters:

  • mixed $sql SQL statement (something like "(select a from tab) as colname" )

  • mixed $arguments SQL arguments.

addJoin

Adds a join clause to the underlying query.

Definition: public function addJoin($j)

Returns: static

Parameters:

  • mixed $j Valid SQL JOIN clause

addMultiAction

Adds a multi-action to the listing.

Definition: public function addMultiAction($label, $url)

Returns: static

Parameters:

  • mixed $label Action label

  • mixed $url URL to be called when the action is triggered

addPager

Adds a pager to the listing

Definition: public function addPager($items_per_page, $allow_reset_pager=true)

Returns: static

Parameters:

  • mixed $items_per_page Items per page

  • mixed $allow_reset_pager Internal: Allows the internal logic to reset the pager to page 1

addRowCallback

Adds a callback for row preprocessing.

Definition: public function addRowCallback($callback)

Returns: static

Parameters:

  • mixed $callback Callback, signature: function($row,$tr){ return $row; }

addRowDataCallback

Adds a callback for data preprocessing.

Definition: public function addRowDataCallback($callback)

Returns: static

Parameters:

  • mixed $callback Callback, signature: function($row){ return $row; }

addSummaryCol

Adds a summary column to the table.

Definition: public function addSummaryCol($name, $label=false, $format=false)

Returns: static

Parameters:

  • mixed $name Column name.

  • mixed $label Column label.

  • mixed $format Column format or callback function.

clearColumns

Clears all columns.

Definition: public function clearColumns()

Returns: static

countRows

Returns the number of found rows. Note that this is not the total number of rows, but the number of rows on the current result page.

Definition: public function countRows()

Returns: mixed

CreateSettingsSnapshot

INTERNAL Used in browser-navigation to jump to the correct listing state.

delColumn

Deletes a column.

Definition: public function delColumn($name)

Returns: static

Parameters:

  • mixed $name Column name

Export

INTERNAL Ajax callback for data export.

extendInnerTable

INTERNAL

filterToVisible

INTERNAL Filter array values to visible values.

getResultSet

INTERNAL Get the underlying ResultSet

GetTableName

Returns the queried tables name.

Definition: public function GetTableName()

Returns: mixed

GotoPage

INTERNAL Will be polled via AJAX to change the page if you defined a pager using DatabaseTable

indexOf

INTERNAL Get index of (visible) column by name.

initDataChanged

INTERNAL

isVisible

Checks if a column is visible

Definition: protected function isVisible($column_name)

Returns: bool True is visible, false otherwise

Parameters:

  • mixed $column_name Column name

Make

Constructs a WdfListing control.

Definition: public static function Make($args)

Returns: static

Parameters:

  • array $args One, two or three arguments. If one, must be Model datatype. If two must be Model datatype and database table, if Three must be Model datatype, UI controller and database table.

makeSlim

SHORTCUT $this->setOptional($columns_to_remove)->setItemsPerPage($items_per_page)

moveColumn

Moves a column to another position.

Definition: public function moveColumn($colToMoveName, $insertBeforeName)

Returns: static

Parameters:

  • mixed $colToMoveName Column name to move

  • mixed $insertBeforeName Column name to insert before

OnAddHeader

INTERNAL Header rendering

OnAddRow

INTERNAL Row rendering

prependColumn

Prepends a column to the list of columns.

Definition: public function prependColumn($name, $label, $format=false, $alignment)

Returns: static

Parameters:

  • mixed $name Column name

  • mixed $label Column label

  • mixed $format Column format or callback with signature function($v,$row){ return 'rendered'; }.

  • mixed $alignment Column alignment.

PreRender

INTERNAL

Reload

INTERNAL Will be polled via AJAX to reload listing. Optionally for a specific state.

Reset

INTERNAL Resets the wrapped DatabaseTable

resetExtension

INTERNAL

ResetPager

Resets the pager to page 1.

Definition: public function ResetPager()

Returns: static

RestoreSettings

INTERNAL Used in automatic setting store

RestoreSettingsSnapshot

INTERNAL Used in browser-navigation to jump to the correct listing state.

setAlignment

Set a columns alignment.

Definition: public function setAlignment($name, $alignment)

Returns: static

Parameters:

  • mixed $name Column name

  • mixed $alignment Column alignment.

setController

Sets the controller to be used as details target.

Definition: public function setController($controller)

Returns: static

Parameters:

  • mixed $controller Controller name

setCulture

Sets the used CultureInfo.

Definition: public function setCulture($ci)

Returns: static

Parameters:

  • \ScavixWDF\Localization\CultureInfo|string $ci The ci to use.

setDataType

Sets the Model datatype.

Definition: public function setDataType($type)

Returns: static

Parameters:

  • mixed $type Model datatype (like MyCustomModel::class)

setEmptyContent

Sets content to be displayed if no data is found.

Definition: public function setEmptyContent($content)

Returns: static

Parameters:

  • mixed $content Content to be displayed.

setExportable

Toggles the export feature.

Definition: public function setExportable($on=true)

Returns: static

Parameters:

  • mixed $on If true, the export feature is enabled.

setFilter

Sets a data filter. Data filters are combined using AND and will be used as WHERE clause. $sql may be a string or a WdfListingFilter object.

Definition: public function setFilter($sql, $params, $replace=false)

Returns: static

Parameters:

  • mixed $sql SQL query or WdfListingFilter object.

  • mixed $params Parameters for the SQL query.

  • mixed $replace If true all previous setFilter calls will be replaced.

SetFilterValues

INTERNAL Sets values for the current WdfListingFilter

setFormat

Set a columns format and alignment.

Definition: public function setFormat($name, $format, $alignment)

Returns: static

Parameters:

  • mixed $name Column name

  • mixed $format Column format or callback with signature function($v,$row){ return 'rendered'; }.

  • mixed $alignment Column alignment.

setGearMode

Set gear mode. "Gear" is the top-right icon that allows advanced listing interaction.

Definition: public function setGearMode($gear_mode, $optional_default=false)

Returns: static

Parameters:

  • mixed $gear_mode Once of the GEAR_MODE_* constants.

  • mixed $optional_default Default 'visible' value for optional columns.

setGroupBy

Sets data grouping.

Definition: public function setGroupBy($groupby)

Returns: static

Parameters:

  • mixed $groupby SQL ready GROUP BY clause (may be just a column name)

setItemsPerPage

Sets pagers items per page.

Definition: public function setItemsPerPage($perpage, $allow_reset_pager=true)

Returns: static

Parameters:

  • mixed $perpage Items per page

  • mixed $allow_reset_pager Internal: Allows the internal logic to reset the pager to page 1

setLabel

Set a columns label.

Definition: public function setLabel($name, $label)

Returns: static

Parameters:

  • mixed $name Column name

  • mixed $label Column label

setLogSql

Toggles SQL logging.

Definition: public function setLogSql($on=true)

Returns: static

Parameters:

  • mixed $on If true, the SQL logging is enabled.

setMultiActionGrouping

Allows tuning the multi-action-grouping feature. If there are many multi-actions, they can be grouped into a select control.

Definition: public function setMultiActionGrouping($on=true, int $treshold)

Returns: static

Parameters:

  • mixed $on If true, grouping will be enabled.

  • int $treshold The minimum number of actions to allow grouping.

setMultiSelectable

Controls the multi-selectable frature.

Definition: public function setMultiSelectable($valuerowid, $checkboxname, $label, $url)

Returns: static

Parameters:

  • mixed $valuerowid Name of the row that holds the dataset id values (id, uid,...)

  • mixed $checkboxname Name of the chackbox controls

  • mixed $label If label and URL are given, shortcuts to WdfListing::addMultiAction

  • mixed $url If label and URL are given, shortcuts to WdfListing::addMultiAction

setMultiSelectableOff

Disables the multi-selectable frature.

Definition: public function setMultiSelectableOff()

Returns: static

setOptional

Sets columns optional, they will be hidden in the GEAR dropdown.

Definition: public function setOptional($column_name)

Returns: static

Parameters:

  • array|string $column_name Column name or array of column names.

setOrder

Sets the order of the listing data. Multiple setOrder calls will result in multiple ORDER BY clauses.

Definition: public function setOrder($orderby)

Returns: static

Parameters:

  • mixed $orderby SQL ready ORDER BY clause (may be just a column name)

setPagerText

Sets a text to be displayed next to the pager.

Definition: public function setPagerText($text)

Returns: static

Parameters:

  • mixed $text Text to be displayed.

setPersistKeyExtra

Sets up an extra key for automatich state storage.

Definition: public function setPersistKeyExtra($extra)

Returns: static

Parameters:

  • mixed $extra Some extra seed

setReadonly

Toggles read-only mode. In read-only mode, the user cannot click on rows to be redirected to 'details' page.

Definition: public function setReadonly($on=true)

Returns: static

Parameters:

  • mixed $on If true, the read-only mode is enabled.

setSortable

Toggles the sorting feature.

Definition: public function setSortable($on=true)

Returns: static

Parameters:

  • mixed $on If true, the sorting feature is enabled.

setSummary

Sets up the summary feature.

Definition: public function setSummary($args)

Returns: static

Parameters:

  • array $args Array of summary specifications, that is column_name, label, format

setTable

Sets the table to be queried for data.

Definition: public function setTable($table)

Returns: static

Parameters:

  • mixed $table Table name

Sort

INTERNAL Switch data sorting

Storage

Returns the storage buffer.

Definition: public static function Storage()

Returns: \ScavixWDF\WdfBuffer

ToggleColumn

INTERNAL Toggles a columns visibility

visibleColumns

INTERNAL Get visible column names.

WdfRender

INTERNAL

Clone this wiki locally