Download the PHP package vkrtecek/table without Composer
On this page you can find all versions of the php package vkrtecek/table. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vkrtecek/table
More information about vkrtecek/table
Files in vkrtecek/table
Package table
Short Description Basic table builder.
License MIT
Homepage https://github.com/vkrtecek/table
Informations about the package table
Easy HTML Table generator
The library focuses on easy table rendering of arrays of objects. No connections to database, only insert array.
License
The Table library is open-sourced software licensed under the MIT license.
Instalation
Examples
Let's say we have for all examples testing class like below:
Basic usage
If we want to render table with collection of TestObject, do:
The string passed by must be the same string as signature of property's getter without . So for example if the TestObject has method , must pass string or .
And in your View call:
or
so the result will look like
ID of person | Name | Age |
---|---|---|
1 | John | 38 |
2 | Susane | 35 |
3 | Paul | 13 |
4 | Joe | 25 |
5 | Lucia | 80 |
6 | Štěpán | 29 |
Advanced
Callbacks
We can specify a callback function instead of property name:
ID of person | Name | Age |
---|---|---|
1 | John | 38 |
2 | Susane | 35 |
3 | Paul | 13 |
4 | John | 38 |
5 | Susane | 35 |
6 | Paul | 13 |
Sorting and filtering table data
Sometimes we need sort data by some attribute:
and now by clicking on the table column header, we can sort the rows by this column. Or pass one parameter of type callable to specify the style of sorting.
By typing code below the field for filtering of specific column data will appear:
If we don't want to show all rows and enable paging, which will render input for number of rows:
Column class
Column can has it's own HTML class
Column filtering
Also for filtering by one single column, there is method which pass string - URL attribute:
will after any table action show URL like
and similar for date column
the URL will look like
for filtering column by "between dates".
If one of these filters are set, the button for show/hide the navigation row will appear above the table. If the "SHOW" button is clicked, navigation row will appear as the second THEAD row.
Additional
If we want to sort and filter data by framework (e.g. QueryBuilder) and pass to table only filtered result set, call
and table skip sorting, filtering and paging. By this integer value is also counted number of pages in listing, so insert the right number.
If is need to customize URL, use method like below:
will cause the URL will look after some table click action like
Table is now multilingual and you can pass your own translations: