Download the PHP package netflex/livewire-tables without Composer
On this page you can find all versions of the php package netflex/livewire-tables. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download netflex/livewire-tables
More information about netflex/livewire-tables
Files in netflex/livewire-tables
Package livewire-tables
Short Description A dynamic Livewire table component for the Netflex SDK
License MIT
Homepage https://github.com/netflex-sdk/livewire-tables
Informations about the package livewire-tables
Netflex Livewire Tables
A datatables Livewire component for the Netflex SDK.
This plugin assumes you already have Laravel Livewire installed and configured in your project.
Installation
You can install the package via composer:
Publishing Assets
Publishing assets are optional unless you want to customize this package.
Usage
Creating Tables
To create a table component you draw inspiration from the below stub:
Your component must implement two methods:
Rendering the Table
Place the following where you want the table to appear.
Netflex SDK 3.x
<livewire:article-table />
Defining Columns
You can define the columns of your table with the column class.
The following methods are available to chain to a column:
Properties
You can override any of these in your table component:
Table
Property | Default | Usage |
---|---|---|
$tableHeaderEnabled | true | Whether or not to display the table header |
$tableFooterEnabled | false | Whether or not to display the table footer |
Searching
Property | Default | Usage |
---|---|---|
$searchEnabled | true | Whether or not searching is enabled |
$searchUpdateMethod | lazy | debounce or lazy |
$searchDebounce | 500 | Amount of time in ms to wait to send the search query and refresh the table |
$disableSearchOnLoading | true | Whether or not to disable the search bar when it is searching/loading new data |
$search | none | The initial search string |
$clearSearchButton | false | Adds a clear button to the search input |
$clearSearchButtonClass | btn btn-outline-dark | The class applied to the clear button |
Sorting
Property | Default | Usage |
---|---|---|
$sortField | id | The initial field to be sorting by |
$sortDirection | asc | The initial direction to sort |
$sortDefaultIcon | <i class="text-muted fas fa-sort"></i> |
The default sort icon |
$ascSortIcon | <i class="fas fa-sort-up"></i> |
The sort icon when currently sorting ascending |
$descSortIcon | <i class="fas fa-sort-down"></i> |
The sort icon when currently sorting descending |
Pagination
Property | Default | Usage |
---|---|---|
$paginationEnabled | true | Enables or disables pagination as a whole |
$perPageOptions | [10, 25, 50, 100, 250, 500] | The options to limit the amount of results per page. Set to [] to disable. |
$perPage | 25 | Amount of items to show per page |
$paginationLocation | 'footer' | Determines location of pagination, can be 'header', 'footer', or 'both' |
Loading
Property | Default | Usage |
---|---|---|
$loadingIndicator | true | Whether or not to show a loading indicator when searching |
$disableSearchOnLoading | true | Whether or not to disable the search bar when it is searching/loading new data |
$collapseDataOnLoading | false | When the table is loading, hide all data but the loading row |
Offline
Property | Default | Usage |
---|---|---|
$offlineIndicator | true | Whether or not to display an offline message when there is no connection |
Exports
Property | Default | Usage |
---|---|---|
$exportFileName | data | The name of the downloaded file when exported |
$exports | [] | The available options to export this table as (csv, xls, xlsx, pdf) |
$exporter | Netflex\Livewire\Tables\Exports\Exporter |
The exporter class to use when generating the output. Must implement the Netflex\Livewire\Tables\Contracts\Exporter contract |
$exportFormats | [...] | Key value array ['format' => Format::class] , can be modified to add support for new formats, default configuation contains formats for PDF, CSV, XLS, and XLSX |
Other
Property | Default | Usage |
---|---|---|
$refresh | false | Whether or not to refresh the table at a certain interval. false = off, int = ms, string = functionCall |
Columns/Data
Use the following methods to alter the column/row metadata.
Pagination
Override these methods if you want to perform extra tasks when the search or per page attributes change.
Search
Override this method if you want to perform extra steps when the search has been cleared.
Sorting
Override this method if you want to change the default sorting behavior.
HTML Components
This package includes some of the functionality from the laravelcollective/html package modified to fit the needs of this package.
To use these you must import the Netflex\Livewire\Tables\Traits\HtmlComponents trait.
You may return any of these functions from the format() method of a column:
Exporting Data
The table component supports exporting to CSV, XLS, XLSX, and PDF.
In order to use this functionality you must install PhpSpreadsheet 1.0 or newer.
What exports your table supports
By default, exporting is off. You can add a list of available export types with the $exports class property.
public $exports = ['csv', 'xls', 'xlsx', 'pdf'];
Defining the file name.
By default, the filename will be data
.type. I.e. data.pdf
, data.csv
.
You can change the filename with the $exportFileName
class property.
public $exportFileName = 'users-table';
- Obviously omit the file type
Deciding what columns to export
You have a couple option on exporting information. By default, if not defined at all, all columns will be exported.
If you have a column that you want visible to the UI, but not to the export, you can chain on excludeFromExport()
If you have a column that you want visible to the export, but not to the UI, you can chain on exportOnly()
Formatting column data for export
By default, the export will attempt to render the information just as it is shown to the UI. For a normal column based attribute this is fine, but when exporting formatted columns that output a view or HTML, it will attempt to strip the HTML out.
Instead, you have available to you the exportFormat()
method on your column, to define how you want this column to be formatted when outputted to the file.
So you can have a column that you want both available to the UI and the export, and format them differently based on where it is being outputted.
Exporting example
Customizing Exports
Currently, there are no customization options available. But there is a config item called exports
where you can define the class to do the rendering. You can use the \Netflex\Livewire\Tables\Exports\Export
class as a base.
More options will be added in the future, but the built in options should be good for most applications.
Setting Component Options
There are some frontend framework specific options that can be set.
These have to be set from the $options
property of your component.
They are done this way instead of the config file that way you can have per-component control over these settings.
For this to work you have to pass an associative array of overrides to the $options
property. The above are the defaults, if you're not changing them then you can leave them out or disregard the property all together.
Passing Properties
To pass properties from your blade view to your table, you can use the normal Livewire mount method:
License
Copyright Apility AS © 2021
Licensed under the MIT License.
This software contains work based on the laravel-livewire-tables package: Copyright © Anthony Rappa and contributors
All versions of livewire-tables with dependencies
illuminate/support Version ^8.27
livewire/livewire Version ^2.0
netflex/api Version ^4.0
netflex/query-builder Version ^4.0
netflex/structures Version ^4.0