Skip to content

myclabs/Datagrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Datagrid - PHP and JS datagrid library

Work under way

Features

  • JS datagrid
  • Datagrid generation with PHP
  • PHP entities/objects datagrid (e.g. Doctrine entities)
  • AJAX: async content loading

screenshot

Basic example

Javascript version:

var example1 = new Datagrid();

example1.addColumns([
	new Column("title", "Title"),
	new Column("description", "Description")
]);

example1.addRows([
	{
		"title":       "Test",
		"description": "This is a long description."
	},
	{
		"title":       "Another test",
		"description": "This is another long description."
	}
]);

example1.render(".datagrid-example");

PHP version:

$example1 = new Datagrid();

$example1->addColumns([
	new Column("title", "Title"),
	new Column("description", "Description"),
]);

$example1->addRows([
	[
		"title" => "Test",
		"description" => "This is a long description.",
	],
	[
		"title" => "Another test",
		"description" => "This is another long description.",
	],
]);

$datagridRenderer = new DatagridRenderer();
$datagridRenderer->render($example1);

Example with entities

$articlesDatagrid = new EntityDatagrid("articles");

$articlesDatagrid->addColumns([
	new TextColumn("title", "Title"),                      // will map to $article->getTitle()
	new LongTextColumn("description", "Description"),      // will map to $article->getDescription()
	new TextColumn("authorName", "Author", "author.name"), // will map to $article->getAuthor()->getName()
]);

$articlesDatagrid->setEntities($articles);

$datagridRenderer = new DatagridRenderer();
$datagridRenderer->render($articlesDatagrid);

Configuration

PHP

See the examples above.

YAML

# views/datagrids/articles.yml
articles:
  type: EntityDatagrid
  columns:
    title:
      type: text
      label: Article title
    description:
      type: longtext
      label: Description
    authorName:
      type: text
      label: Author
      path: author.name
$articlesDatagrid = Datagrid::build("articles");
$articlesDatagrid->setEntities($articles);

$datagridRenderer = new DatagridRenderer();
$datagridRenderer->render($articlesDatagrid);

Dependencies

Javascript:

  • jQuery
  • Bootstrap (soft dependency, only used for layout and CSS)

PHP:

  • Doctrine Collections: 1.*
  • Symfony YAML: 2.*
  • Symfony PropertyAccess

(dependencies are managed through Composer)

About

PHP and JS datagrid library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published