Contributte Datagrid-elasticsearch-data-source

Website 🚀 contributte.org | Contact 👨🏻‍💻 f3l1x.io | Twitter 🐦 @contributte

# Disclaimer

⚠️ This project is no longer being maintained. Please use ublaboo/datagrid (opens new window).
Composer ublaboo/datagrid-elasticsearch-data-source (opens new window)
Version
PHP
License

# Documentation

# Usage

<?php

namespace App\Presenters;

use Elasticsearch\Client;
use Nette\Application\UI\Presenter;
use Ublaboo\DataGrid\DataGrid;
use Ublaboo\DatagridElasticsearchDataSource\ElasticsearchDataSource;

final class UsersPresenter extends Presenter
{

	/**
	 * @var ElasticsearchDataSource
	 */
	private $elasticsearchDataSource;


	public function __construct(Client $client)
	{
		$this->elasticsearchDataSource = new ElasticsearchDataSource(
			$client, // Elasticsearch\Client
			'users', // Index name
			'user' // Index type
		);
	}


	public function createComponentUsersGrid(): DataGrid
	{
		$grid = new DataGrid;

		$grid->setDataSource($this->elasticsearchDataSource);

		$grid->addColumnText('id', '#')->setSortable();
		$grid->addColumnLink('nickname', 'Nickname', 'edit')
			->setFilterText();
		$grid->addColumnText('username', 'E-mail (username)')
			->setFilterText();
		$grid->addColumnText('age', 'Age')
			->setSortable()
			->setFilterRange();
		$grid->addColumnText('status', 'Status')
			->setFilterMultiSelect([
				'active' => 'Active',
				'disabled' => 'Disabled',
			]);
		$grid->addColumnDateTime('created', 'Created')
			->setFormat('j. n. Y H:i:s')
			->setFilterDateRange();

		return $grid;
	}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

# Development

This package was maintain by these authors.


Consider to support (opens new window) contributte development team. Also thank you for being used this package.