Fork me on GitHub

Mesour Filter

A lot of ways to filter data ;-)

Packagist

  • jQuery 2.0+ Download
  • Twitter bootstrap 3.2+ Download
  • Bootstrap 3 Datepicker (in default, can change) v4 Download
  • Font Awesome (in default, can change) 4.5+ Download
  • mesour.components.min.js
  • mesour.filter.min.js
  • mesour.filter.min.css

Installation

Suggests

  • None

Demo

Initializing

$data = array(
    array(
        'user_id' => '1','action' => '0','group_id' => '1',
        'name' => 'John','surname' => 'Doe','email' => 'john.doe@test.xx',
        'last_login' => '2014-09-01 06:27:32','amount' => '1561.456542',
        'avatar' => '/avatar/01.png','order' => '100','timestamp' => '1418255325'
    ),
    // etc...
);

$groups = array(
    array('id' => '2', 'name' => 'Group 2'),
    array('id' => '1', 'name' => 'Group 1'),
    array('id' => '3', 'name' => 'Group 3'),
);

$application = new \Mesour\UI\Application;

$application->setRequest($_REQUEST);

$filter = new \Mesour\UI\Filter('test');

$application->addComponent($filter);

$source = new \Mesour\Filter\Sources\ArrayFilterSource($data, array(
    'group' => $groups
));

$source->setRelated('group', 'group_id', 'name', 'group_name');

$filter->setSource($source);

$filter->addTextFilter('name', 'Name');

$filter->addNumberFilter('amount', 'Amount');

$filter->addDateFilter('last_login', 'Last login');

$filter->addTextFilter('group_name', 'Group name');

$filter->addDateFilter('timestamp', 'Last login');

$filter->onRender[] = function(\Mesour\UI\Filter $_filter) {
    //dump($_filter->getValues());
};

echo $filter->render();

Demo