Skip to content
This repository was archived by the owner on Jun 10, 2022. It is now read-only.

Commit c68cf55

Browse files
committed
Modified grid columns
1 parent 5ffae3a commit c68cf55

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

src/CS/DataGridBundle/Grid/Collection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function addRecursive($data = array())
9898
{
9999
if (is_array($data) && !empty($data)) {
100100
foreach ($data as $key => $column) {
101-
$this->add($column, $key);
101+
$this->add($column, null, $key);
102102
}
103103
}
104104

src/CS/DataGridBundle/Grid/Column/ColumnCollection.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ class ColumnCollection extends Collection
2121
* @param string $label
2222
* @param integer $priority
2323
*/
24-
public function add($label, $priority = 0)
24+
public function add($label, $callback = null, $priority = 0)
2525
{
2626
// TODO: get column class from configuration
27-
$column = new Column ($label);
27+
$column = new Column ($label, $callback);
2828

2929
$this->offsetSet($priority, $column);
3030

src/CS/DataGridBundle/Grid/Grid.php

+14-9
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Grid
3333
*/
3434
protected $grid;
3535

36-
public static $columnCollection;
36+
public $columnCollection;
3737

3838
/**
3939
* Constructor
@@ -122,7 +122,7 @@ public function setGrid(GridInterface $grid)
122122
{
123123
$this->grid = $grid;
124124

125-
//$grid->setContainer($this->getContainer());
125+
$grid->setContainer($this->getContainer());
126126
return $this;
127127
}
128128

@@ -136,17 +136,22 @@ public function getContainer()
136136
return $this->container;
137137
}
138138

139-
public function getColumns()
139+
protected function fetchColumns()
140140
{
141-
if (!self::$columnCollection) {
142-
self::$columnCollection = new ColumnCollection;
141+
if(!$this->columnCollection instanceof ColumnCollection)
142+
{
143+
$this->columnCollection = new ColumnCollection;
143144

144-
self::$columnCollection->addRecursive($this->data->getColumns());
145+
$this->columnCollection->addRecursive($this->data->getColumns());
145146

146-
$this->grid->getColumns(self::$columnCollection);
147-
}
147+
$this->grid->getColumns($this->columnCollection);
148+
}
149+
}
148150

149-
return self::$columnCollection;
151+
public function getColumns()
152+
{
153+
$this->fetchColumns();
154+
return $this->columnCollection;
150155
}
151156

152157
public function getActions()

src/CS/DataGridBundle/Grid/Row.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ public function offsetExists($offset)
122122
try {
123123
$val = $this->getValue($offset);
124124
} catch (\Exception $e) {
125-
return false;
125+
126+
$cols = $this->getGrid()->getColumns();
127+
128+
return is_object($cols[$offset]);
126129
}
127130

128131
return true;

0 commit comments

Comments
 (0)