Download the PHP package nerweb/laravel-tblist without Composer
On this page you can find all versions of the php package nerweb/laravel-tblist. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-tblist
laravel-tblist
Simple admin table listing for bootstrap 3 and laravel 4|5
Installation
Add the following to your composer.json
file:
Then, run composer update nerweb/laravel-tblist
or composer install
if you have not already installed packages.
and
Publish assets:
Simple Example
First, create a class name UserTblist
.
Create a route and and its controller. insert below inside the controller method.
Create the blade user/index.blade.php
and insert below.
For complete example, see example
folder.
API Reference
Note! Child class should always extend Nerweb\Tblist\BaseTblist
.
Column
The column
property accepts a data for column name as a key and column options as a value.
Column key
The column key
may or may not exists in the result row. Column key also assumes
as the name to be sorted.
Note! if column key
doesn't exists in the result row, you should create a protected method colSetTheColumnName
as custom column.
Column options
Options | type | Description |
---|---|---|
label |
string |
Column header label. |
sortable |
bool |
Whether sortable or not. |
table_column |
string |
if set, then use its value instead of the column key as the column name to sort (i.e roles.admin , users.admin ). |
classes |
string |
table column classes. Note! Both applied to header, footer and body column. |
thead_attr |
string |
Table header attribute. |
Note! All column option
is default to null
.
Custom Column Display
Add protected method colSetColumnNameToCamel
(i.e colSetUsername
, colSetCreatedAt
) that only accepts 1 parameter an object of result row. Then echo or display the string.
Example
in your class, UserTblist
for this example. Add this next to setColumns
method
Custom Column
Sometimes we want to show column that is not in the result object row.
To do this, add a column key
to columns
property and make sure that the sortable
options is set to false
.
and
create a method called colSetYourColumnName($row)
that accepts result row.
Multiple Tblist
Sometimes we want to display multiple table listing on the same page.
To do this,
- on class initialization, in this case
$list = new UserTblist()
. Override base URL via$list->setBaseURL($url, $parameters)
method. - set the tblist form action with
$list->getBaseURL()
. - create the route with controller and return the json data of the tblist.
Demo
see simple demo here
License
This project is open-sourced software licensed under the MIT license.