sg/datatablesbundle

Symfony Datatable Bundle For Doctrine2 Entities

Installs: 20 765

Dependents: 2

Stars: 94

Watchers: 30

Forks: 70

Open Issues: 10

Type: symfony-bundle

v0.9 2016-01-09 18:00 UTC

README

SensioLabsInsight

knpbundles.com

Latest Stable Version Total Downloads Latest Unstable Version License

1. Recent Changes

In-place editing

In-place editing for text, datetime and boolean fields added (before usage you should manually include dependent x-editable js and css files).

Example:

->add('title', 'column', array(
    'title' => 'Titel',
    'editable' => true
))
->add('publishedAt', 'datetime', array(
    'title' => 'PublishedAt',
    'name' => 'daterange',
    'date_format' => 'll',
    'editable' => true
))
->add('visible', 'boolean', array(
    'title' => 'Visible',
    'editable' => true
))
Screenshot

Token for multiselect actions

The multiselect ajax request sends now a CSRF-Token.

Update your bulk-actions like this:

/**
 * Bulk delete action.
 *
 * @param Request $request
 *
 * @Route("/bulk/delete", name="post_bulk_delete")
 * @Method("POST")
 *
 * @return Response
 */
public function bulkDeleteAction(Request $request)
{
    $isAjax = $request->isXmlHttpRequest();

    if ($isAjax) {
        $choices = $request->request->get('data');
        $token = $request->request->get('token');

        if (!$this->isCsrfTokenValid('multiselect', $token)) {
            throw new AccessDeniedHttpException('The CSRF token is invalid.');
        }

        $em = $this->getDoctrine()->getManager();
        $repository = $em->getRepository('AppBundle:Post');

        foreach ($choices as $choice) {
            $entity = $repository->find($choice['value']);
            $em->remove($entity);
        }

        $em->flush();

        return new Response('Success', 200);
    }

    return new Response('Bad Request', 400);
}

2. Screenshots

Table with Bootstrap3 integration:

Screenshot

Table with default stylesheet (display):

Screenshot

3. Documentation

Installation

Column types

In-place editing

How to use the ColumnBuilder

Setup Datatable Class

Filtering

To use a line formatter

Query callbacks

Extensions like Buttons or Responsive

Options of the generator

Reference configuration

4. Examples

Examples

Demo Application - must be updated!

5. Integrating 3rd party stuff

Integrate Bootstrap3

Integrate the Translatable behavior extension for Doctrine 2

Integrate the LiipImagineBundle / ImageColumn, GalleryColumn and thumbnails

6. Creating an Admin Section (unstable)

Admin section

7. Limitations and Known Issues

Much like every other piece of software SgDatatablesBundle is not perfect and far from feature complete.

Use this Bundle in ServerSide mode

The ClientSide mode currently does not work with all features. There are some problems with the Buttons-Extension and MultiSelectColumn. At the moment I can not say whether the ClientSide mode is supported by me in the future. Priority has the ServerSide mode.

Other limitations

  • This bundle does not support multiple Ids
  • 4th level associations are currently not supported
  • Searching and filtering on a virtual column not yet implemented and disabled by default
  • PostgreSql is not supported

8. Reporting an issue or a feature request

Issues and feature requests are tracked in the Github issue tracker.

9. Friendly License

This bundle is available under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE

You are free to use, modify and distribute this software, as long as the copyright header is left intact (specifically the comment block which starts with /*)!