Skip to content

Commit

Permalink
Add more flexibility for table control column
Browse files Browse the repository at this point in the history
For example
$display = AdminDisplay::table();
$display->getControlColumn()->getHeader()->setTitle('Control')->setAttribute('class', 'bg-black');
or
$display->setControlColumn(new AdminColumn::customControl(...))
  • Loading branch information
butschster committed Feb 24, 2016
1 parent 0e45774 commit 7366a51
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/Display/DisplayTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ class DisplayTable implements Renderable, DisplayInterface
*/
protected $paginate;

/**
* @var Column\Control
*/
protected $controlColumn;

public function __construct()
{
$this->controlColumn = TableColumn::control();
}

/**
* @param string $class
*/
Expand All @@ -105,6 +115,26 @@ public function getClass()
return $this->class;
}

/**
* @param ColumnInterface $controlColumn
*
* @return $this
*/
public function setControlColumn(ColumnInterface $controlColumn)
{
$this->controlColumn = $controlColumn;

return $this;
}

/**
* @return Column\Control
*/
public function getControlColumn()
{
return $this->controlColumn;
}

public function initialize()
{
Meta::loadPackage(get_called_class());
Expand Down Expand Up @@ -147,8 +177,9 @@ public function setColumns(array $columns)
public function getAllColumns()
{
$columns = $this->getColumns();

if ($this->isControlActive()) {
$columns[] = TableColumn::control();
$columns[] = $this->getControlColumn();
}

return $columns;
Expand Down Expand Up @@ -180,6 +211,8 @@ public function setWith($with)

/**
* @param Closure $apply
*
* @return $this
*/
public function setApply(Closure $apply)
{
Expand Down

0 comments on commit 7366a51

Please sign in to comment.