Exemple #1
0
 /**
  * Create Column object based on given options and add it to the grid
  *
  * @param string $columnTitle title of a column
  * @param array  $column      array of column options
  *
  * @return \SynergyDataGrid\Grid\JqGridFactory
  */
 public function addColumn($columnTitle = '', $column = array())
 {
     if (is_array($column) && count($column) && array_key_exists('name', $column) && $columnTitle) {
         $columnName = $column['name'];
         $existingColumn = $this->getColumn($columnName);
         // if column with such a name already exists we will merge options and overwrite title with new one
         if ($existingColumn) {
             $utils = new ArrayUtils();
             $oldOptions = $existingColumn->getOptions();
             $newOptions = $utils->arrayMergeRecursiveCustom($oldOptions, $column);
             $columnObject = new Column($newOptions, $this);
         } else {
             $columnObject = new Column($column, $this);
         }
         $columnObject->setTitle($columnTitle);
         $this->_columns[$columnName] = $columnObject;
     }
     return $this;
 }