Download the PHP package avpretty/grid-bundle without Composer

On this page you can find all versions of the php package avpretty/grid-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package grid-bundle

Overview

Allows you to quickly display the data of any entity or array in the form of a table. This table already contains filtering, sorting and pagination.

So using 9 lines of code you can build something like this

Installation

install the GridBundle executing this console command in your project:

Update your AppKernel.php:

GridBundle contains js and css and you need to include them manually. To use code example below the AsseticBundle must be installed:

NOTE: GridBundle uses bootstrap framework and jQuery.

Grid View

GridView is the main component that allows you to create and manage you grid. Each grid for each entity or array requires new instance of GridView.

Shortest way to create new grid:

And update your template:

DONE!

GridViewBundle provides a lot of options for configure your grid. Detailed explanation of sorting, filtering, pagination and columns options are described in corresponding sections of this documentation.

Extended example:

GridView options: Grid filter options:

Nested Grid

You can insert one grid into another. To do this you need to render nested grid manually:

Grid Filters

By default grid filters are disabled. To enable them add next code to your grid configuration:

Specifying entity instance you allowed to build filter fields.

By default filter fields will be created for each entity attributes. But you also can add filter fields for custom column.

Example:

NOTE: If you won't specify filter type then symfony will try to guess it. Concerning this you might got an error Unable to transform value for property path.... The main reason of this is doctrine fields validation so there are two options: manually specify filter type like shown above or remove validation.

You can get all available filter types at symfony's form documentation as well as filter options.

In case of using ArrayDataSource you should still specify filter entity (any).

Grid filter options:

Full example for User entity. We have next fields: firstName, lastName and created. Let's create search method in UserRepository:

Now let's describe our filters in Controller:

Now filter form will be displayed and you are able to work with incoming filter data.

Filters with relations

Also you can apply filters to related entities. For example we will be using User entity and related Country entity. Let's create dropdown filter by country.

NOTE!!!: TO BE ABLE TO USE FILTRATION ON RELATED ENTITIES YOU SHOULD SPECIFY THOSE ENTITIES IN YOUR QUERY BUILDER. DO NOT USE PROXY OBJECTS.

Example:

Some explanation to example above: attributeName is compulsory and it's value should be specified in User entity. You also can specify arbitrary value of attributeName BUT selected filter value won't be remembered by form field UNLESS you add this field to target (User) entity.

Columns

Columns provides simple interface for controlling data displaying within grid. There are three types of columns and one base interface BaseColumn:

Column

Responsible for rendering common data within grid. This type of column displays all user data such as entities or arrays. There are a bunch of display options that can be customize by user.

For example we will be using QueryDataSource of User entity.Our entity contains next fields: firstName, lastName, age, email, created.

Simple example:

NOTE: If we just omit column configuration the result will be the same.

In case of using relations you can use next syntax:

Extended example:

Column options:

CounterColumn

Provides simple counter for table rows. Included by default for both data sources QueryDataSource and ArrayDataSource.

Inherits most properties of data column.

Example:

ActionColumn

Action columns allows to create control buttons for each grid row. For now there are two types of buttons: show, edit. Each button configurable. Action columns will be included to grid by default IF you are using QueryDataSource in other case you should specify it manually.

NOTE: By default all action buttons will be visible and will use the current route. Also there is no need to specify each button manually. They will be displayed by default.

Example:

Each button has two configurable options: url, visibility. Both options accept both a scalar value and a callback function.

If you are using callback function there are two arguments available:

buttons and hiddenButtons values are optional. By default for url creation will be used current route with show path and edit respectively.

For example if current url is .../admin/user/ then for show button will be generated next url .../admin/user/{userId}/show until you won't change it.

Column data format

This component allow to apply different format type to Column data. There are four available formats:

Example:

DataSource

This entity acts as an intermediary between the grid and the data source. It is this component that creates the final query and passes the result of its execution to the grid component that works with the BaseDataSource interface.

There are two entities that implements BaseDataSource:

QueryDataSource

QueryDataSource allows to pass your instance of QueryBuilder to grid. Example:

NOTE: There is no need to manually configure sort and pagination for QueryDataSource. Each instance of BaseDataSource is created with sort and pagination with default params. For example if we did not specify sorting params then all field of User entity will be sortable.

Now we can get user entities with sorting and pagination settings, using fetchEntities:

NOTE: As mentioned above we should specify entity alias like we did it for User. Concerning this we should ALWAYS specify entity alias for QueryDataSource. If you won't do this then alias will be taken from entity name and it will be User. The reason of this is default sorting configuration that should know full field name. From the other hand you will use constructions like JOIN.

ArrayDataSource

ArrayDataSource allows to pass your array data to grid.

Example:

Now we can pass our $dataSource to grid and it will be properly displayed.

NOTE: We did not set alias u for sorting as in case of QueryDataSource. We should use only array keys while working with ArrayDataSource.

Sort

The sorting component allows you to flexibly set and expand the sorting parameters for specific attributes. You can use this component with one of the data source component (QueryDataSource or ArrayDataSource).

Let's assume that we have User entity with next fields:

Example:

If attribute name specified without any params then default params will be used. Next example shows how the email attribute will be interpreted.

The attribute names used in the configuration are the names of the entity fields if you are using the QueryDataSource and the array keys name if you are using the ArrayDataSource.

NOTE: In expanded attribute configuration we used custom field title name but specified sortable fields using specified alias u. In case of short notation we should specify entity alias like we did it with u.email.

Attribute options:

There are few additional params of Sort instance that can be configured:

Relation Sort

As well as filter you can sort by related entities fields. For example we will be using User entity and related Country entity.

NOTE!!!: TO BE ABLE TO USE SORT ON RELATED ENTITIES YOU SHOULD SPECIFY THOSE ENTITIES IN YOUR QUERY BUILDER. DO NOT USE PROXY OBJECTS.

Example:

Some explanation to example above: c is Country entity alias that you should specify in you query builder.

Pagination

Pagination component allows you to easily limit the amount of data displayed on the page. This component consists from three parts:

Pagination example:

Using these parameters, the pagination component is able to generate the values of the limit and offset based on the query parameters.

NOTE: There might be a names conflict. For example one of your routes already uses page query param name. In that case you can rename page param name:

Pagination options:

NOTE: BaseDataSource instances already contains pagination instance. So there is no need to specify pagination instance manually and set it to QueryDataSource or ArrayDataSource. Instead default pagination configuration will be used.

To display pagination block call twig extension in you template:

gridPagination extension can apply additional params. ALL PARAMETERS ARE OPTIONAL:


All versions of grid-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
symfony/framework-bundle Version ~2.3|~3.0
symfony/dependency-injection Version ~2.3|~3.0
twig/twig Version ~1.12|~2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package avpretty/grid-bundle contains the following files

Loading the files please wait ....