2017 © Pedro Peláez
 

library phalcon-datatables

DataTables adapter for Phalcon Framework

image

m1ome/phalcon-datatables

DataTables adapter for Phalcon Framework

  • Friday, November 27, 2015
  • by m1ome
  • Repository
  • 12 Watchers
  • 46 Stars
  • 16,859 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 39 Forks
  • 9 Open issues
  • 12 Versions
  • 7 % Grown

The README.md

Build Status Build Status Coverage Status, (*1)

Total Downloads License Dependency Status, (*2)

About

This is a Phalcon Framework adapter for DataTables., (*3)

Support

Currently supported

  • QueryBuilder interface
  • ResultSet interface
  • Pagination
  • Global search (by value)
  • Ordering
  • Multiple column ordering
  • Column-based search

Installation

Installation via Composer

  • Install a composer
  • Create composer.json file inside your project directory
  • Paste into it
{
    "require": {
        "m1ome/phalcon-datatables": "1.*"
    }
}
  • Run composer update

Example usage

It uses Phalcon QueryBuilder for pagination in DataTables., (*4)

In example we have a stantart MVC application, with database enabled. Don't need to provide a normal bootstrap PHP file, for Phalcon documentation, visit official site., (*5)

Controller (using QueryBuilder):

<?php
use \DataTables\DataTable;

class TestController extends \Phalcon\Mvc\Controller {
    public function indexAction() {
        if ($this->request->isAjax()) {
          $builder = $this->modelsManager->createBuilder()
                          ->columns('id, name, email, balance')
                          ->from('Example\Models\User');

          $dataTables = new DataTable();
          $dataTables->fromBuilder($builder)->sendResponse();
        }
    }
}

Controller (using ResultSet):

<?php
use \DataTables\DataTable;

class TestController extends \Phalcon\Mvc\Controller {
    public function indexAction() {
        if ($this->request->isAjax()) {
          $resultset  = $this->modelsManager->createQuery("SELECT * FROM \Example\Models\User")
                             ->execute();

          $dataTables = new DataTable();
          $dataTables->fromResultSet($resultset)->sendResponse();
        }
    }
}

Controller (using Array):

<?php
use \DataTables\DataTable;

class TestController extends \Phalcon\Mvc\Controller {
    public function indexAction() {
        if ($this->request->isAjax()) {
          $array  = $this->modelsManager->createQuery("SELECT * FROM \Example\Models\User")
                             ->execute()->toArray();

          $dataTables = new DataTable();
          $dataTables->fromArray($array)->sendResponse();
        }
    }
}

Model:

<?php
/**
* @property integer id
* @property string name
* @property string email
* @property float balance
*/
class User extends \Phalcon\Mvc\Model {
}

View:

<html>
    <head>
        <title>Simple DataTables Application</title>
        <script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                $('#example').DataTable({
                    serverSide: true,
                    ajax: {
                        url: '/test/index',
                        method: 'POST'
                    },
                    columns: [
                        {data: "id", searchable: false},
                        {data: "name"},
                        {data: "email"},
                        {data: "balance", searchable: false}
                    ]
                });
            });
        </script>
    </head>
    <body>
        <table id="example">
            <thead>
                <th>ID</th>
                <th>Username</th>
                <th>Email</th>
                <th>Balance</th>
            </thead>
            <tbody>
            </tbody>
        </table>
    </body>
</html>

More examples

For more examples please search in site directory. It contains basic Phalcon bootstrap page to show all Phalcon-DataTables functionality., (*6)

The Versions

27/11 2015

dev-master

9999999-dev

DataTables adapter for Phalcon Framework

  Sources   Download

MIT

The Development Requires

by Pavel Makarenko

plugin datatables phalcon

27/11 2015

1.1.7

1.1.7.0

DataTables adapter for Phalcon Framework

  Sources   Download

MIT

The Development Requires

by Pavel Makarenko

plugin datatables phalcon

27/11 2015

dev-dev

dev-dev

DataTables adapter for Phalcon Framework

  Sources   Download

MIT

The Development Requires

by Pavel Makarenko

plugin datatables phalcon

26/06 2015

1.1.6

1.1.6.0

DataTables adapter for Phalcon Framework

  Sources   Download

MIT

The Development Requires

by Pavel Makarenko

plugin datatables phalcon

28/02 2015

1.1.5

1.1.5.0

DataTables adapter for Phalcon Framework

  Sources   Download

MIT

The Development Requires

by Pavel Makarenko

plugin datatables phalcon

25/02 2015

1.1.4

1.1.4.0

DataTables adapter for Phalcon Framework

  Sources   Download

MIT

The Development Requires

by Pavel Makarenko

plugin datatables phalcon

24/02 2015

1.1.3

1.1.3.0

DataTables adapter for Phalcon Framework

  Sources   Download

MIT

The Development Requires

by Pavel Makarenko

plugin datatables phalcon

24/02 2015

1.1.2

1.1.2.0

DataTables adapter for Phalcon Framework

  Sources   Download

MIT

The Development Requires

by Pavel Makarenko

plugin datatables phalcon

08/02 2015

1.1.1

1.1.1.0

DataTables adapter for Phalcon Framework

  Sources   Download

MIT

The Development Requires

by Pavel Makarenko

plugin datatables phalcon

08/02 2015

1.1.0

1.1.0.0

DataTables adapter for Phalcon Framework

  Sources   Download

MIT

The Development Requires

by Pavel Makarenko

plugin datatables phalcon

07/02 2015

1.0.1

1.0.1.0

DataTables adapter for Phalcon Framework

  Sources   Download

MIT

The Development Requires

by Pavel Makarenko

plugin datatables phalcon

06/02 2015

1.0.0

1.0.0.0

DataTables adapter for Phalcon Framework

  Sources   Download

MIT

The Development Requires

by Pavel Makarenko

plugin datatables phalcon