This repository was archived by the owner on Jun 10, 2022. It is now read-only.
File tree 4 files changed +21
-13
lines changed
src/CS/DataGridBundle/Grid
4 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ public function addRecursive($data = array())
98
98
{
99
99
if (is_array ($ data ) && !empty ($ data )) {
100
100
foreach ($ data as $ key => $ column ) {
101
- $ this ->add ($ column , $ key );
101
+ $ this ->add ($ column , null , $ key );
102
102
}
103
103
}
104
104
Original file line number Diff line number Diff line change @@ -21,10 +21,10 @@ class ColumnCollection extends Collection
21
21
* @param string $label
22
22
* @param integer $priority
23
23
*/
24
- public function add ($ label , $ priority = 0 )
24
+ public function add ($ label , $ callback = null , $ priority = 0 )
25
25
{
26
26
// TODO: get column class from configuration
27
- $ column = new Column ($ label );
27
+ $ column = new Column ($ label, $ callback );
28
28
29
29
$ this ->offsetSet ($ priority , $ column );
30
30
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ class Grid
33
33
*/
34
34
protected $ grid ;
35
35
36
- public static $ columnCollection ;
36
+ public $ columnCollection ;
37
37
38
38
/**
39
39
* Constructor
@@ -122,7 +122,7 @@ public function setGrid(GridInterface $grid)
122
122
{
123
123
$ this ->grid = $ grid ;
124
124
125
- // $grid->setContainer($this->getContainer());
125
+ $ grid ->setContainer ($ this ->getContainer ());
126
126
return $ this ;
127
127
}
128
128
@@ -136,17 +136,22 @@ public function getContainer()
136
136
return $ this ->container ;
137
137
}
138
138
139
- public function getColumns ()
139
+ protected function fetchColumns ()
140
140
{
141
- if (!self ::$ columnCollection ) {
142
- self ::$ columnCollection = new ColumnCollection ;
141
+ if (!$ this ->columnCollection instanceof ColumnCollection)
142
+ {
143
+ $ this ->columnCollection = new ColumnCollection ;
143
144
144
- self :: $ columnCollection ->addRecursive ($ this ->data ->getColumns ());
145
+ $ this -> columnCollection ->addRecursive ($ this ->data ->getColumns ());
145
146
146
- $ this ->grid ->getColumns (self ::$ columnCollection );
147
- }
147
+ $ this ->grid ->getColumns ($ this ->columnCollection );
148
+ }
149
+ }
148
150
149
- return self ::$ columnCollection ;
151
+ public function getColumns ()
152
+ {
153
+ $ this ->fetchColumns ();
154
+ return $ this ->columnCollection ;
150
155
}
151
156
152
157
public function getActions ()
Original file line number Diff line number Diff line change @@ -122,7 +122,10 @@ public function offsetExists($offset)
122
122
try {
123
123
$ val = $ this ->getValue ($ offset );
124
124
} catch (\Exception $ e ) {
125
- return false ;
125
+
126
+ $ cols = $ this ->getGrid ()->getColumns ();
127
+
128
+ return is_object ($ cols [$ offset ]);
126
129
}
127
130
128
131
return true ;
You can’t perform that action at this time.
0 commit comments