All Projects → pedro-teixeira → grid-bundle

pedro-teixeira / grid-bundle

Licence: MIT license
A Symfony2 Ajax Grid

Programming Languages

PHP
23972 projects - #3 most used programming language
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to grid-bundle

Griddle
Simple Grid Component written in React
Stars: ✭ 2,494 (+14570.59%)
Mutual labels:  grid
React Datepicker
An easily internationalizable, accessible, mobile-friendly datepicker library for the web, build with styled-components.
Stars: ✭ 252 (+1382.35%)
Mutual labels:  grid
react-bolivianite-grid
React grid component for virtualized rendering large tabular data.
Stars: ✭ 95 (+458.82%)
Mutual labels:  grid
Leerraum.js
A PDF typesetting library with exact positioning and hyphenated line breaking
Stars: ✭ 233 (+1270.59%)
Mutual labels:  grid
Tablefilter
A Javascript library making HTML tables filterable and a bit more :)
Stars: ✭ 248 (+1358.82%)
Mutual labels:  grid
CentrifugoBundle
📦 Provides communication with web-socket server Centrifugo in Symfony applications.
Stars: ✭ 65 (+282.35%)
Mutual labels:  bundle
Styled Components Grid
A responsive grid components for styled-components.
Stars: ✭ 218 (+1182.35%)
Mutual labels:  grid
react-datasheet-grid
An Airtable-like / Excel-like component to create beautiful spreadsheets.
Stars: ✭ 227 (+1235.29%)
Mutual labels:  grid
Bootstrap 4 Grid
Bootstrap 4 grid system and layout utilities.
Stars: ✭ 251 (+1376.47%)
Mutual labels:  grid
yii2-grid-view-library
Highly enhanced GridView widget and grid components for Yii2
Stars: ✭ 57 (+235.29%)
Mutual labels:  grid
Blueprint Css
📘 Blueprint CSS is a modern responsive CSS layout library & grid built on top of CSS Grid and Flexbox.
Stars: ✭ 233 (+1270.59%)
Mutual labels:  grid
Blazortable
Blazor Table Component with Sorting, Paging and Filtering
Stars: ✭ 249 (+1364.71%)
Mutual labels:  grid
gulp-rev-versions-bundle
A bundle that allows symfony to get the version of assets versioned with gulp-rev
Stars: ✭ 13 (-23.53%)
Mutual labels:  bundle
Jqwidgets
Angular, Vue, React, Web Components, Blazor, Javascript, jQuery and ASP .NET Framework,
Stars: ✭ 227 (+1235.29%)
Mutual labels:  grid
geogrid.js
Leaflet plugin for Visualizing Discrete Global Grid Systems
Stars: ✭ 37 (+117.65%)
Mutual labels:  grid
Element Tree Grid
tree grid extends element ui with vue
Stars: ✭ 223 (+1211.76%)
Mutual labels:  grid
css-grid-playground
A simple interface for experimenting with CSS Grid Layout.
Stars: ✭ 84 (+394.12%)
Mutual labels:  grid
parcel-plugin-externals
Parcel plugin for declaring externals. These externals will not be bundled. 📦
Stars: ✭ 47 (+176.47%)
Mutual labels:  bundle
SensioBuzzBundle
No description or website provided.
Stars: ✭ 89 (+423.53%)
Mutual labels:  bundle
SonataTimelineBundle
[Abandoned] Integrates SpyTimelineBundle into Sonata
Stars: ✭ 24 (+41.18%)
Mutual labels:  bundle

pedro-teixeira/grid-bundle

Build Status Version Downloads License

Ajax grid for Symfony2

Example

Using Twitter Bootstrap, jQuery Bootstrap Datepicker and fake data with Faker.

Requirements

  1. Twitter Bootstrap (not mandatory)
    • If you choose to don't use Twitter Bootstrap, it'll be necessary to create your own style.
  2. jQuery Bootstrap Datepicker (not mandatory)
    • If you choose to don't use Bootstrap Datepicker, please disable the datepicker as default in the configuration, "use_datepicker".

Installation

  1. Add as a dependency in your composer file

    "require": {
        "pedro-teixeira/grid-bundle":"dev-master"
    }
  2. Add to your Kernel

    // application/ApplicationKernel.php
    public function registerBundles()
    {
        $bundles = array(
            new PedroTeixeira\Bundle\GridBundle\PedroTeixeiraGridBundle()
        );
     }
  3. Add to your assetics configuration

    # application/config/config.yml
    assetic:
        bundles: [ PedroTeixeiraGridBundle ]
  4. Add assets to your layout

    {% stylesheets
        '@PedroTeixeiraGridBundle/Resources/public/css/grid.css'
    %}
    <link href="{{ asset_url }}" type="text/css" rel="stylesheet" media="screen" />
    {% endstylesheets %}
    {% javascripts
        '@PedroTeixeiraGridBundle/Resources/public/js/grid.js'
    %}
    <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}
  5. (optional) Adjust configurations

    # application/config/config.yml
    pedro_teixeira_grid:
        defaults:
            date:
                use_datepicker:     true
                date_format:        'dd/MM/yy'
                date_time_format:   'dd/MM/yy HH:mm:ss'
            pagination:
                limit:              20
            export:
                enabled:            true
                path:               '/tmp/'

    The configuration "use_datepicker" will set the input type as "text" and attach a jQuery plugin "datepicker()" to the filter.

Create your grid

  1. Create the grid class

    In your bundle, create a folder named "Grid" (or wathever namespace you want) and create your grid definition class.

    <?php
    
    namespace PedroTeixeira\Bundle\TestBundle\Grid;
    
    use PedroTeixeira\Bundle\GridBundle\Grid\GridAbstract;
    
    /**
     * Test Grid
     */
    class TestGrid extends GridAbstract
    {
        /**
         * {@inheritdoc}
         */
        public function setupGrid()
        {
            $this->addColumn('Hidden Field')
                ->setField('hidden')
                ->setIndex('r.hidden')
                ->setExportOnly(true);
    
            $this->addColumn('ID')
                ->setField('id')
                ->setIndex('r.id')
                ->getFilter()
                    ->getOperator()
                        ->setComparisonType('equal');
    
            $this->addColumn('Created At')
                ->setField('createdAt')
                ->setIndex('r.createdAt')
                ->setFilterType('date_range')
                ->setRenderType('date');
    
            $this->addColumn('Name')
                ->setField('name')
                ->setIndex('r.name');
    
            $this->addColumn('Number')
                ->setField('number')
                ->setIndex('r.number')
                ->setFilterType('number_range');
    
            $this->addColumn('Options')
                ->setField('option')
                ->setIndex('r.options')
                ->setFilterType('select')
                ->getFilter()
                    ->setOptions(array(
                        'key' => 'value'
                    ));
    
            $this->addColumn('Action')
                ->setTwig('PedroTeixeiraTestBundle:Test:gridAction.html.twig')
                ->setFilterType(false);
        }
    }
  2. Use the grid factory in your controller

    <?php
    
    namespace PedroTeixeira\Bundle\TestBundle\Controller;
    
    use Symfony\Bundle\FrameworkBundle\Controller\Controller;
    
    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
    
    use JMS\SecurityExtraBundle\Annotation\Secure;
    
    /**
     * Default controller
     */
    class DefaultController extends Controller
    {
        /**
         * @Route("/", name="test")
          * @Template()
          *
          * @return array
          */
        public function indexAction()
        {
            /** @var \Doctrine\ORM\EntityRepository $repository */
            $repository = $this->getDoctrine()->getRepository('PedroTeixeiraTestBundle:TestEntity');
            $queryBuilder = $repository->createQueryBuilder('r');
    
            /** @var \PedroTeixeira\Bundle\TestBundle\Grid\TestGrid $grid */
            $grid = $this->get('pedroteixeira.grid')->createGrid('\PedroTeixeira\Bundle\TestBundle\Grid\TestGrid');
            $grid->setQueryBuilder($queryBuilder);
    
            if ($grid->isResponseAnswer()) {
                return $grid->render();
            }
    
            return array(
                'grid'   => $grid->render()
            );
        }
    }
  3. Render in your template

    {{ pedroteixeira_grid(grid) }}

    Or if you want to render the grid's html and the grid's js separately:

     {{ pedroteixeira_grid_html(grid) }}
     
     ...
     
     {{ pedroteixeira_grid_js(grid) }}

Understanding

Continuous integration

To execute locally the checks that are executed on Travis:

composer install
find ./Grid ./DependencyInjection ./Twig -name "*.php" -exec php -l {} \;
./bin/phpcs --extensions=php --standard=PSR2 ./Grid ./DependencyInjection ./Twig
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].