All Projects → KilikFr → TableBundle

KilikFr / TableBundle

Licence: MIT License
Symfony Bundle for easy pagination and filtering

Programming Languages

PHP
23972 projects - #3 most used programming language
Twig
543 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to TableBundle

Exopite-Multifilter-Multi-Sorter-WordPress-Plugin
Display and/or sort/filter any page or post types by multiple taxonomies or terms (like post by categories and/or tags) with AJAX. Exopite multifilter, multi-sortable, multi selectable, multi filterable sortable Wordpress Plugin.
Stars: ✭ 18 (-25%)
Mutual labels:  pagination, filter, ajax
Filterable
Filtering from incoming params in Elixir/Ecto/Phoenix with easy to use DSL.
Stars: ✭ 83 (+245.83%)
Mutual labels:  pagination, filter
Queryql
Easily add filtering, sorting, and pagination to your Node.js REST API through your old friend: the query string!
Stars: ✭ 76 (+216.67%)
Mutual labels:  pagination, filter
Tablefilter
A Javascript library making HTML tables filterable and a bit more :)
Stars: ✭ 248 (+933.33%)
Mutual labels:  pagination, filter
Gridjs
Advanced table plugin
Stars: ✭ 3,231 (+13362.5%)
Mutual labels:  pagination, filter
Sieve
⚗️ Clean & extensible Sorting, Filtering, and Pagination for ASP.NET Core
Stars: ✭ 560 (+2233.33%)
Mutual labels:  pagination, filter
Jsonapi.rb
Lightweight, simple and maintained JSON:API support for your next Ruby HTTP API.
Stars: ✭ 116 (+383.33%)
Mutual labels:  pagination, filter
spring-boot-jpa-rest-demo-filter-paging-sorting
Spring Boot Data JPA with Filter, Pagination and Sorting
Stars: ✭ 70 (+191.67%)
Mutual labels:  pagination, filter
ember-cli-blog
Tom Dale's blog example updated for the Ember CLI
Stars: ✭ 87 (+262.5%)
Mutual labels:  pagination, filter
repository
[PHP 7] Implementation and definition of a base Repository in Domain land.
Stars: ✭ 26 (+8.33%)
Mutual labels:  pagination, filter
Graphql To Mongodb
Allows for generic run-time generation of filter types for existing graphql types and parsing client requests to mongodb find queries
Stars: ✭ 261 (+987.5%)
Mutual labels:  pagination, filter
activeadmin-ajax filter
AJAX filters for ActiveAdmin
Stars: ✭ 86 (+258.33%)
Mutual labels:  filter, ajax
react-strap-table
react table (client and server-side) based on bootstrap.
Stars: ✭ 28 (+16.67%)
Mutual labels:  pagination, filter
Datagrid
Datagrid for Laravel v5
Stars: ✭ 44 (+83.33%)
Mutual labels:  pagination, filter
flop
Filtering, ordering and pagination for Ecto
Stars: ✭ 56 (+133.33%)
Mutual labels:  pagination, filter
Bpage
Based on bootstrap style, static page jump can also be asynchronous page processing pagination plugin
Stars: ✭ 96 (+300%)
Mutual labels:  pagination, ajax
Vue2 Bootstrap Table
A sortable and searchable table, as a Vue2 component, using bootstrap styling.
Stars: ✭ 120 (+400%)
Mutual labels:  filter, ajax
Ajaxinate
🎡 Ajax pagination plugin for Shopify themes
Stars: ✭ 107 (+345.83%)
Mutual labels:  pagination, ajax
express-mquery
Expose mongoose query API through HTTP request.
Stars: ✭ 37 (+54.17%)
Mutual labels:  pagination, filter
ULogViewer
Cross-Platform Universal Log Viewer.
Stars: ✭ 64 (+166.67%)
Mutual labels:  filter, customizable

README

What's KilikTableBundle ?

KilikTableBundle is a fast, modern, and easy-to-use way to manipulate paginated information, with filtering and ordering features, with ajax queries.

This bundle is a work in progress.

Links:

Working features:

  • pagination
  • basic filtering (like %...%)
  • advanced filtering (<,>,<=,>=,=,!,!=)
  • ordering by column (and reverse)
  • basic table template extendable
  • keep filters and orders in browser local storage (api REST)
  • filtering on queries with group by
  • show ordered column (normal and reverse)
  • max items per page selector (customizable)
  • delay on keyup events (to prevent multiple reloads)
  • checkbox and select filter
  • CSV export of filtered rows
  • customization of visible columns (hide/show checkboxes)
  • column display colum cells with callback
  • custom display colum cells with template
  • multiple lists on one page
  • pre-load default filters and reset local storage filters
  • smart filtering on many words (Filter::TYPE_LIKE_WORDS_AND)
  • (beta) support api calls to load resources via web services

Planned features:

  • more translations
  • add advanced templates

Installation

composer require kilik/table

Patch your AppKernel.php (symfony <4):

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...
            new \Kilik\TableBundle\KilikTableBundle(),
        ];
        
        // ...
    }
}    

Patch your AppKernel.php (symfony >=4):

<?php

return [
    Kilik\TableBundle\KilikTableBundle::class => ['all' => true],
];

Install assets

./bin/console assets:install --symlink

And create your first list:

Feature disabled on 1.0 branch (symfony 4 compatibility WIP)

./bin/console kilik:table:generate

(With default parameters, your list is available here http://localhost/yourcontroller/list)

Usage

This documentation need to be completed.

Here, some examples to show latest features.

Optimized version to load entities, from Repository Name:

$table = (new Table())
    // ...
    ->setEntityLoaderRepository("KilikDemoBundle:Product")
    // ...

Optimized version to load entities, from Callback method (Eager loading):

$table = (new Table())
    // ...
    ->setEntityLoaderCallback(function($ids) {
        return $this->manager()->getRepository('KilikDemoBundle:Product')->findById($ids);
    })
// ...

Mass actions

Define a mass action for list

$massAction = new MassAction('delete', 'Delete selected items'); 
// First parameter 'delete' must not contain space or special characters (identifier)
$massAction->setAction('path/to/my-form-action.php');

$table = (new Table())
    // ...
    ->addMassAction($massAction)
    // ...
    
// Then your form action, you can grab selected rows as entities
$selectedEntities = $this->get('kilik_table')
    ->getSelectedRows($request, $this->getTable());

foreach ($selectedEntities as $entity) {
    // ...
    $entity->doSomething();
    // ...
}

If mass action does not have a specified action, a javascript event is fired. You can get all rows checked as following :

 $("#table_id").on('kilik:massAction', function (e, detail) {
    if (detail.checked.length === 0) return false;
    if (detail.action === 'delete') {
        //...
    }
});

Events / Listeners

  • kilik:init:start jQuery event when table init process starts
$(document).on('kilik:init:start', function(event, table) {
    // Do something with event or table object
});
  • kilik:init:end jQuery event when table init process ends
$(document).on('kilik:init:start', function(event, table) {
    // Do something with event or table object
});

Autoload Kilik Tables

A new twig block provide metadata information about table so you can autoload it if necessary without any javascript in your twig template.

{% block tableMetadata %}
    <div style="display:none;width:0; height:0;" data-kiliktable-id="{{ table.id }}" data-kiliktable-path="{{ table.path }}">{{ table.options | json_encode | raw }}</div>
{% endblock tableMetadata %}

You can access table configurations from HTML attributes with jQuery, see the example :

var loadKiliktables = function() {
    var $kilikTables = $("[data-kiliktable-id]");
    if ($kilikTables && $kilikTables.length > 0) {
        $kilikTables.each(function(index, currentTable){
            var $currentTable = $(currentTable);
            var id = $currentTable.data("kiliktable-id");
            if (id.length > 0) {
                var path = $currentTable.data("kiliktable-path");
                var options = $currentTable.html();
                new KilikTableFA(id, path, JSON.parse(options)).init();
            }
        });
    }
}

Bootstrap 4

Note: WIP on Bootstrap 4 (with Font Awesome) integration, use new JS function:

$(document).ready(function () {
    var table = new KilikTableFA("{{ table.id }}", "{{ table.path }}", JSON.parse('{{ table.options | json_encode |raw }}'));
    table.init();
});

Use other storage for table filters

If you want to use a custom storage for table filters (Eg. Session).

// Disable using javascript local storage form filters
public function getTable()
{
    return (new Table())->setSkipLoadFilterFromLocalStorage(true);
}

// On ajax action : store filters data
public function _list(Request $request)
{
    $table = $this->getTable();
    $response = $this->get('kilik_table')->handleRequest($table, $request);
    
    // Handle request for table form
    $this->kilik->createFormView($table);
    $table->getForm()->handleRequest($request);
    $data = $table->getForm()->getData();
    
    $this->filterStorage->store($data); // Use your custom storage

    return $response;
}


// On default action
public function list()
{
    $table = $this->getTable();
    $data = $this->filterStorage->get();

    return $this->render('list.html.twig', array(
        'table' => $this->kilik->createFormView($table, $data),
    ));
}

For bundle developpers

# prepare tests
./prepare-tests.sh

# run tests
./run-tests.sh

# launch composer
./scripts/composer.sh
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].