Ublaboo\DataGrid\Column\ItemDetail::setType PHP Method

setType() public method

Set item detail type
public setType ( string $type )
$type string
    public function setType($type)
    {
        $this->type = (string) $type;
        return $this;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Items can have thair detail - toggled
  * @param mixed $detail callable|string|bool
  * @param bool|NULL $primary_where_column
  * @return Column\ItemDetail
  */
 public function setItemsDetail($detail = TRUE, $primary_where_column = NULL)
 {
     if ($this->isSortable()) {
         throw new DataGridException('You can not use both sortable datagrid and items detail.');
     }
     $this->items_detail = new Column\ItemDetail($this, $primary_where_column ?: $this->primary_key);
     if (is_string($detail)) {
         /**
          * Item detail will be in separate template
          */
         $this->items_detail->setType('template');
         $this->items_detail->setTemplate($detail);
     } else {
         if (is_callable($detail)) {
             /**
              * Item detail will be rendered via custom callback renderer
              */
             $this->items_detail->setType('renderer');
             $this->items_detail->setRenderer($detail);
         } else {
             if (TRUE === $detail) {
                 /**
                  * Item detail will be rendered probably via block #detail
                  */
                 $this->items_detail->setType('block');
             } else {
                 throw new DataGridException('::setItemsDetail() can be called either with no parameters or with parameter = template path or callable renderer.');
             }
         }
     }
     return $this->items_detail;
 }