2017 © Pedro Peláez
 

symfony-bundle table-bundle

Table component integration

image

ekyna/table-bundle

Table component integration

  • Tuesday, June 5, 2018
  • by ekyna
  • Repository
  • 2 Watchers
  • 1 Stars
  • 512 Installations
  • HTML
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 2 % Grown

The README.md

TableBundle

Table component integration., (*1)

Instation

  1. Through Composer
    composer require ekyna/table-bundle:0.1.*@dev
  1. Register the bundle in your AppKernel
    // app/AppKernel.php
    public function registerBundles()
    {
        $bundles = array(
            // other bundles ...
            new Ekyna\Bundle\TableBundle\EkynaTableBundle(),
        );

        return $bundles;
    }

Usage

  1. Create the table type
    // src/Acme/DemoBundle/Table/Type/BrandType.php
    namespace Acme\DemoBundle\Table\Type;

    use Ekyna\Component\Table\AbstractTableType;
    use Ekyna\Component\Table\TableBuilderInterface;
    use Symfony\Component\OptionsResolver\OptionsResolverInterface;

    class BrandType extends AbstractTableType
    {
        public function buildTable(TableBuilderInterface $tableBuilder)
        {
            $tableBuilder
                ->addColumn('id', 'number', array(
                    'sortable' => true,
                ))
                ->addColumn('title', 'text', array(
                    'label' => 'Title',
                    'sortable' => true,
                ))
                ->addFilter('id', 'number')
                ->addFilter('title', 'text', array(
                    'label' => 'Title'
                ))
            ;
        }

        public function setDefaultOptions(OptionsResolverInterface $resolver)
        {
            parent::setDefaultOptions($resolver);

            $resolver->setDefaults(array(
                'data_class' => 'Acme\DemoBundle\Entity\Brand',
            ));
        }

        public function getName()
        {
            return 'acme_demo_brand';
        }
    }
  1. (optional) Register the table type as a service
    <!-- src/Acme/DemoBundle/Resources/config/services.xml -->
    <service id="acme_demo.table_type.brand" class="Acme\DemoBundle\Table\Type\BrandType">
        <tag name="table.type" alias="acme_demo_brand" />
    </service>
  1. Create the controller
    // src/Acme/DemoBundle/Controller/BrandController.php
    namespace Acme\Demo\Controller;

    use Symfony\Bundle\FrameworkBundle\Controller\Controller;
    use Symfony\Component\HttpFoundation\Request;
    // use Acme\DemoBundle\Table\Type\BrandType;

    class ResourceController extends Controller
    {
        public function indexAction(Request $request)
        {
            $table = $this->get('table.factory')
                /*->createBuilder(new BrandType(), array( // instance
                    'name' => 'my_brand_list,
                ))*/
                ->createBuilder('acme_demo_brand', array( // service
                    'name' => 'my_brand_list',
                ))
                ->getTable($request)
            ;

            return $this->render('AcmeDemoBundle:Brand:index.html.twig', array(
                'brands' => $table->createView(),
            ));
        }
    }
  1. Create the twig template
    # src/Acme/DemoBundle/Resources/views/Brand/index.html.twig
    <!DOCTYPE html>
    <html>
        <head>
            {% stylesheets output='css/main.css'
                'css/bootstrap.css'
                '@EkynaTableBundle/Resources/asset/css/table.css'
            -%}
            <link href="{{ asset_url }}" rel="stylesheet" type="text/css" />
            {% endstylesheets %}
        </head>
        <body>
            {{ ekyna_table_render(brands) }}

            {% javascripts output='js/main.js'
                'js/jquery.js'
                'js/bootstrap.js'
                '@EkynaTableBundle/Resources/asset/js/table.js'
            -%}
            <script type="text/javascript" src="{{ asset_url }}"></script>
            {%- endjavascripts %}
        </body>
    </html>

Customization

The default template used to render the table is vendor/ekyna/table-bundle/Ekyna/Bundle/TableBundle/Resources/views/ekyna_table.html.twig. It requires jQuery and Bootstrap 3., (*2)

You can create your own rendering template (where you will define all blocks of the default template) and use it this way, (*3)

    {{ ekyna_table_render(brands, {'template': 'AcmeDemoBundle:Table:render.html.twig'}) }}

TODO

  • Tests
  • Type inheritance
  • AJAX
  • Adapters (ORM, ODM, PHPCR)
  • Render engines
  • More documentation (columns, filter, internals, ...)

The Versions

05/06 2018

0.7.x-dev

0.7.9999999.9999999-dev https://github.com/ekyna/TableBundle

Table component integration

  Sources   Download

MIT

The Requires

 

bundle table symfony

25/04 2017

0.6.x-dev

0.6.9999999.9999999-dev https://github.com/ekyna/TableBundle

Table component integration

  Sources   Download

MIT

The Requires

 

symfony2 bundle table

14/12 2015

0.2.x-dev

0.2.9999999.9999999-dev https://github.com/ekyna/TableBundle

Table component integration

  Sources   Download

MIT

The Requires

 

symfony2 bundle table

10/12 2015

0.4.x-dev

0.4.9999999.9999999-dev https://github.com/ekyna/TableBundle

Table component integration

  Sources   Download

MIT

The Requires

 

symfony2 bundle table

02/12 2015

0.5.x-dev

0.5.9999999.9999999-dev https://github.com/ekyna/TableBundle

Table component integration

  Sources   Download

MIT

The Requires

 

symfony2 bundle table

06/11 2015

dev-master

9999999-dev https://github.com/ekyna/TableBundle

Table component integration

  Sources   Download

MIT

The Requires

 

symfony2 bundle table

28/10 2015

0.3.x-dev

0.3.9999999.9999999-dev https://github.com/ekyna/TableBundle

Table component integration

  Sources   Download

MIT

The Requires

 

symfony2 bundle table

22/04 2015

v0.1

0.1.0.0 https://github.com/ekyna/TableBundle

Table component integration

  Sources   Download

MIT

The Requires

 

symfony2 bundle table

08/04 2015

dev-templating

dev-templating https://github.com/ekyna/TableBundle

Table component integration

  Sources   Download

MIT

The Requires

 

symfony2 bundle table