Download the PHP package pawellen/listing without Composer
On this page you can find all versions of the php package pawellen/listing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pawellen/listing
More information about pawellen/listing
Files in pawellen/listing
Package listing
Short Description Listing Bundle providing easy datatables (http://www.datatables.net/) usage in symfony projects
License MIT
Homepage https://github.com/pawellen/listing
Informations about the package listing
listing
Builder style data table backend plugin for datatables.net js plugin
Version 2 with Symfony 4.4 support
Based on: https://github.com/pawellen/DataTablesListing
DataTables Listing plugin
Data tables listing plugin allow you to easy creating record list, using Symfony forms style. This plugin use popular JQuery DataTables plug (http://www.datatables.net/)
Installation
-
Install plugin using composer:
- Update Your AppKernel.php
html
(...)
{{ listing_scripts() }}
(...)
(...)
twig {% extends "PanelBundle::base_template.html.twig" %}
{% form_theme list.filters _self %}
{% block _my_list_widget %}
{% endblock _my_list_widget %}
{% block content_body %} {{ listing(list) }} {% endblock %}
To render entire listing, you can use ***listing()*** twig function. This example shows also how to overwrite filters template. Notice that there is a leading underscore in block name.
Functions
===
1. Creating links
---
To create link you need to add ***link*** option inside ***buildListing*** method.
where:
***id*** is a ***propertyPath*** string.
***route*** is a route name
***params*** are parameters to generateUrl function
2. Using QueryBuilder
---
To use query builder you need to use ***query_builder*** option instead of class.
or
3. Using filters
---
By default, when building filters form you don't need to define any filters, you may pass empty array as filter options, in this case
default search will be performed. Default search use "name LIKE %PHRASE%" sql query, where ***name*** is filter name and ***PHRASE***
is the value of input. To use custom filter just pass the DQL expression to filter option.
Example:
where:
***expression*** is a DQL expression, You can use parameter multiple times, for example: "u.firstname LIKE :name OR u.lastname LIKE :name".
***eval*** is not required parameter it is used to modify value passed from filter form
notice:
***:name*** MUST be always same as filter name (in current version)
4. Using query modifications when filter is used
---
In some cases your listing is very simple but there is case when you use some filters you have to add some complicated joins, but in other cases you don't want
apply that joins to query because they are very expensive.
Example:
In this example when user fill "Language code" filter, ***join('c.language')*** will be added and languageCode condition will be added to query.
***Deprecated*** parameter joins (used in old version):
In this case country will be joined only if country filter is passed by user, otherwise joins are not used.
5. Buttons
---
Inside ***buildListing*** method you can add action buttons to your list position.
Example:
6. Events
---
When you need dynamically modify/extend table rows or filters search criteria you can use one of listing events.
7. Accessing custom properties via PropertyAccessor
---
When using ***query_bulder*** you can use option ***property*** to access any data from fetched entity. For example:
If you have related entity you can can access its getter threw property accessor:
or you can even can access first object in collection:
listing allow you tu use some magic wildcard ***[*]***, to collect all values in collection and display it as coma
separated string:
***NOTE:*** You can use onlu one wildcard in your property option.