|
pclib
3.2.0
Lightweight PHP framework
|
Displaying tabular data in table layout. More...
Public Member Functions | |
| setPage ($page) | |
| Set active (selected) page. More... | |
| setQuery ($sql) | |
| Set sql query which will be used as datasource for the grid. More... | |
| setArray (array $dataArray, $totalLength=0) | |
| Set php array which will be used as datasource for the grid. More... | |
| setSelection (orm\Selection $sel) | |
| Set Selection $sel which will be used as datasource for the grid. More... | |
| summary ($field, $sql='', $sumblock='summary') | |
| Enable summarization rows. More... | |
| setSort ($s) | |
| Enable sorting. More... | |
| loadSession () | |
| Load grid object from session. More... | |
| saveSession () | |
| Save grid object to session. More... | |
| print_Element ($id, $sub, $value) | |
| This function is called for each template tag when it is printed. More... | |
| print_Pager ($id, $sub) | |
| Print grid pager. More... | |
| print_Sort ($id, $sub) | |
| Print sort-link. More... | |
| create ($tableName, $templatePath='') | |
| Use default template for displaying database table content. | |
| getExportCsv ($options=[], $page=null) | |
| Return content of the grid as csv-text. More... | |
| exportCsv ($fileName, $options=array()) | |
| Show download dialog for csv-file with content of the grid. More... | |
| exportExcel ($fileName) | |
| Show download dialog for csv-file with content of the grid. More... | |
Public Member Functions inherited from Tpl | |
| __construct ($path='', $sessName='') | |
| Load and parse template file. More... | |
| init () | |
| Initialization - must be called after load() | |
| load ($path) | |
| Load template file. More... | |
| loadString ($s) | |
| Load string $s as template. More... | |
| out ($block=null) | |
| Display template populated with content. More... | |
| html ($block=null) | |
| Return html output of the template populated with content. More... | |
| enable () | |
| Enable (show) or disable (hide) tag or block $name. More... | |
| disable () | |
| Disable (hide) tag or block $name. More... | |
| setAttr ($id, $value, $value2=null) | |
| Set attribute globally for template elements. More... | |
| getBlock ($block) | |
| Return values of block $block. More... | |
| getValue ($id) | |
| Return value of element $id. More... | |
| deleteSession () | |
| Remove object from session. | |
| print_Number ($id, $sub, $value) | |
| Print numeric $value. More... | |
| print_String ($id, $sub, $s) | |
| Print string $value. More... | |
| print_Bind ($id, $sub, $value) | |
| Bind $value to LABEL coming from datasource and print LABEL. More... | |
| print_Link ($id, $sub, $value) | |
| Create html link. More... | |
| print_Env ($id, $sub, $value) | |
| Print value from url (from _GET array). More... | |
| print_Class ($id, $sub, $value) | |
| Print all fields into template. More... | |
| print_Action ($id, $sub, $value) | |
| Call controller's method and include result into template. More... | |
| print_Block ($block) | |
| Print template block. More... | |
| addTag ($line) | |
| Add new element. More... | |
| addType ($name, $fn) | |
| Add new type of element handled by callback function $fn. More... | |
| setFields ($fields) | |
| Show only this $fields in template (using tag {grid.fields} or {form.fields}). More... | |
| htmlTag ($name, $attr=[], $content=null) | |
| Return html tag $name with attributes. More... | |
Public Member Functions inherited from BaseObject | |
| loadDefaults ($className=null) | |
| Load default parameters of class $className into object instance. | |
| setProperties (array $defaults) | |
| Set public properties of object from the array. More... | |
| toArray () | |
| Convert object to array. More... | |
Static Public Member Functions | |
| static | invalidate ($sessName) |
| Invalidate grid $sessname. More... | |
Static Public Member Functions inherited from BaseObject | |
| static | defaults () |
| Set or retireve default parameters of the object. More... | |
Data Fields | |
| $length = 0 | |
| Number of rows of the grid. | |
| $filter = array() | |
| array filter - Values of current filter. | |
| $multiSort = false | |
| enable sorting by more than one column. | |
| $pager | |
| var GridPager | |
| $sortArray = array() | |
| Current sorting. | |
Data Fields inherited from Tpl | |
| $name | |
| Name of the template. | |
| $elements = array() | |
| Array of elements loaded from <?elements ? > section. | |
| $values = array() | |
| Array of template values. | |
| $db | |
| var Db | |
| $router | |
| var Router | |
| $escapeHtmlFunction | |
| Function for escaping html in template values. | |
Data Fields inherited from BaseObject | |
| $serviceLocator | |
| var function() Return service object when requested with service(). | |
Protected Member Functions | |
| _init () | |
| Initialization - must be called after load() | |
| initPager () | |
| Create and configure grid pager. | |
| getPager () | |
| Return instance of GridPager. | |
| _out ($block=null) | |
| Display datagrid. More... | |
| sortUrl ($id) | |
| Return url for sortlink. | |
| trPrintElement ($elem) | |
| Implements {grid.labels} and {grid.items} placeholders. More... | |
| getVariable ($id) | |
| Get template variable tvar... | |
| getValues () | |
| Load values for current page from database (fill tpl::values array). More... | |
| setLength ($length) | |
| Set grid->length (total number of rows). More... | |
| getDataArray () | |
| Load values for current page from dataarray (array-based grid). More... | |
| getSummary ($block) | |
| Get summary row for summarization grid. | |
| applyFilter (array $dataArray) | |
| Apply filter on arraygrid. | |
| getQuery () | |
| Build grid query and return result (resource). More... | |
| getBaseUrl () | |
| get proper base url for grid sort and pager & other links | |
Protected Member Functions inherited from Tpl | |
| getAttr ($id, $attr) | |
| Return attribute of element $id. More... | |
| getRowNo () | |
| Return row number of the current block. | |
| createFromTable ($tableName, $templatePath) | |
| Use default template for displaying database table content. | |
| compute ($id) | |
| Return computed value of element $id. | |
| getPopup ($id, $attr, $url) | |
| Generate javascript code for popup window. More... | |
| getUrl ($elem) | |
| Return url for the element (button, link) with completed parameters. | |
| formatDate ($dtstr, $fmt='') | |
| DATABASE DATE => HUMAN DATE (in date() format) More... | |
| formatStr ($s, $fmt) | |
| Format string $s according format $fmt. | |
| getItems ($id) | |
| Load lookup table for elements such as bind, select, check or radio. More... | |
Protected Member Functions inherited from BaseObject | |
| service ($service, $default=null) | |
| Try acquire $service and load it into property $this->$service. More... | |
Protected Attributes | |
| $dataArray | |
| Array of values for array-based grid. | |
| $sumArray | |
| Summary fields (if any). | |
| $sql | |
| grid sql query. | |
| $className = 'grid' | |
| Name of the 'class' element. | |
Protected Attributes inherited from Tpl | |
| $sessName | |
| Name of the session variable where template values are stored. More... | |
| $app | |
| var App Link to application object. | |
| $config = null | |
| Link to array of configuration parameters. | |
| $document | |
| Document array - It contains parsed template. | |
| $parser | |
| var TplParser | |
| $fields = [] | |
| List of id's to be printed in {grid.fields} tag. | |
| $types = [] | |
| Additional element type handlers. | |
Displaying tabular data in table layout.
Features:
Class Grid implements following template tags:
class, sort, pager
See also Template tags implemented by class Grid
|
protected |
Display datagrid.
| string | $block | If set, only block $block will be shown. |
Reimplemented from Tpl.
| exportCsv | ( | $fileName, | |
$options = array() |
|||
| ) |
Show download dialog for csv-file with content of the grid.
| array | $options |
| exportExcel | ( | $fileName | ) |
Show download dialog for csv-file with content of the grid.
|
protected |
Load values for current page from dataarray (array-based grid).
| getExportCsv | ( | $options = [], |
|
$page = null |
|||
| ) |
Return content of the grid as csv-text.
| array | $options | [csv-separ: ';', csv-row-separ: "\n"] |
|
protected |
Build grid query and return result (resource).
setquery() is required before calling this function.
|
protected |
Load values for current page from database (fill tpl::values array).
tpl::values are not cleared, so you can add additional fields from the code.
|
static |
Invalidate grid $sessname.
Update number of pages of session grid, if it is changed for example by adding/deleting rows in table.
| loadSession | ( | ) |
Load grid object from session.
Called when $sessname in constructor is set. Do not call directly. "Session" grid is necessary, if you need remember current page, sorting and filter after page-reload.
Reimplemented from Tpl.
| print_Element | ( | $id, | |
| $sub, | |||
| $value | |||
| ) |
This function is called for each template tag when it is printed.
| string | $id | name of template tag {ID} |
| string | $sub | modificator (second part) of template tag name {ID.sub} |
| mixed | $value | value of element going from Tpl->values array |
Reimplemented from Tpl.
| print_Pager | ( | $id, | |
| $sub | |||
| ) |
Print grid pager.
{pager} tag will show default pager, for modificators - see Template tags implemented by class Grid.
| string | $id | name of template tag {ID} |
| string | $sub | modificator (second part) of template tag name {ID.sub} |
| mixed | $value | value of element going from Tpl->values array |
| print_Sort | ( | $id, | |
| $sub | |||
| ) |
Print sort-link.
| string | $id | name of template tag {ID} |
| string | $sub | modificator (second part) of template tag name {ID.sub} |
| mixed | $value | value of element going from Tpl->values array |
| saveSession | ( | ) |
Save grid object to session.
Called when $sessname in constructor is set. Do not call directly. "Session" grid is necessary, if you need remember current page, sorting and filter after page-reload.
Reimplemented from Tpl.
| setArray | ( | array | $dataArray, |
$totalLength = 0 |
|||
| ) |
Set php array which will be used as datasource for the grid.
| string | $dataArray | - Array of rows: [$row1, $row2, ...]. |
| string | $totalLength | Total number of rows (optional) (Use this, if you desire send to grid not all rows, but only one page at the time). |
|
protected |
Set grid->length (total number of rows).
| int | $length | Number of rows |
| setPage | ( | $page | ) |
Set active (selected) page.
| int | $page | Page number |
| setQuery | ( | $sql | ) |
Set sql query which will be used as datasource for the grid.
For info about SQL parameters and grid filtering see Dynamic SQL.
| string | $sql | Sql query. Only SELECT-queries are allowed. |
| setSelection | ( | orm\Selection | $sel | ) |
Set Selection $sel which will be used as datasource for the grid.
| orm\Selection | $sel |
| setSort | ( | $s | ) |
Enable sorting.
Example: $grid->setSort('field1,field2');
| string | $s | fieldlist |
| summary | ( | $field, | |
$sql = '', |
|||
$sumblock = 'summary' |
|||
| ) |
Enable summarization rows.
When $field value changes, summary block is pushed into grid output.
| string | $field | GROUP BY field |
| string | $sql | Sumarization query |
| string | $sumblock | Name of the summary block (must exists in template) |
|
protected |
Implements {grid.labels} and {grid.items} placeholders.
| string | $id | name of template tag {ID} |
| string | $sub | modificator (second part) of template tag name {ID.sub} |
| mixed | $value | value of element going from Tpl->values array |
Reimplemented from Tpl.