setPrimaryKey() 공개 메소드

By default ID, you can change that
public setPrimaryKey ( string $primary_key ) : static
$primary_key string
리턴 static
예제 #1
0
 /**
  * Create grid UI component (Ublaboo/DataGrid
  *
  * @param array|IRepository|Selection          $data
  * @param string                               $primaryKey
  * @param integer                              $perPage
  * @param array                                $permanentlyFilter
  * @param Nette\ComponentModel\IContainer|null $parent
  * @param string|null                          $name
  *
  * @return DataGrid
  * @throws DataGridException
  */
 public function createUblaboo($data = null, $primaryKey = null, $perPage = null, $permanentlyFilter = [], $parent = null, $name = null)
 {
     $grid = new DataGrid($parent, $name);
     // set primary key
     if ($primaryKey) {
         $grid->setPrimaryKey($primaryKey);
     }
     // set data source
     if ($data) {
         if ($data instanceof IRepository) {
             $dataSource = new Mepatek\Components\Ublaboo\DataSources\RepositorySource($data, $primaryKey);
             $dataSource->setPermanentlyFilter($permanentlyFilter);
         } elseif ($data instanceof Selection) {
             $dataSource = new NetteDatabaseTableDataSource($data, $primaryKey);
         } else {
             $dataSource = new ArrayDataSource($data);
         }
         $grid->setDataSource($dataSource);
     } else {
         $dataSource = new ArrayDataSource([]);
         $grid->setDataSource($dataSource);
     }
     // set properties of grid
     if ($this->translator) {
         $grid->setTranslator($this->translator);
     }
     //$grid->setEditableColumns();
     $grid->setRememberState(true);
     // set item per page
     if ($perPage) {
         $grid->per_page = $perPage;
     }
     return $grid;
 }