Skip to content
This repository
Browse code

Pass ID for expanders in table_id in addition to id

Currently the page inside expander gets ID of the row user
has clicked on through $_GET['id']. With this fix user also
can get id through $_GET['thetable_id']. The table is determined
properly from attached model, associtated dq table if grid
is static - page name. Finally it can be specified
manually too.
  • Loading branch information...
commit 6788f40c1fd8fb6d38df79c709c3f7990fffe11c 1 parent a29ef4c
Romans Malinovskis authored March 23, 2011

Showing 1 changed file with 25 additions and 1 deletion. Show diff stats Hide diff stats

  1. 26  lib/Grid.php
26  lib/Grid.php
@@ -265,7 +265,10 @@ function format_expander($field, $column){
265 265
 						array('expander'=>$field,
266 266
 							'cut_page'=>1,
267 267
 							'expanded'=>$this->name,
268  
-							'id'=>$this->current_row[$column['idfield']?$column['idfield']:'id']
  268
+
  269
+                            // TODO: id is obsolete
  270
+							'id'=>$this->current_row[$column['idfield']?$column['idfield']:'id'],
  271
+							$this->columns[$field]['refid'].'_id'=>$this->current_row[$column['idfield']?$column['idfield']:'id']
269 272
 							)
270 273
 						).'"
271 274
 			>'.$this->current_row[$field].'</button>';
@@ -274,6 +277,27 @@ function init_expander_widget($field){
274 277
 		return $this->init_expander($field);
275 278
 	}
276 279
 	function init_expander($field){
  280
+
  281
+        if(!isset($this->columns[$field]['refid'])){
  282
+            // TODO: test
  283
+        
  284
+            $refid=$this->getController();
  285
+            if($refid)$refid=$refid->getModel();
  286
+            if($refid)$refid=$refid->entity_code;
  287
+            if($refid){
  288
+                $this->columns[$field]['refid']=$refid;
  289
+            }else{
  290
+
  291
+                if($this->dq)
  292
+                    $refid=$this->dq->args['table'];
  293
+
  294
+                if(!$refid)$refid=preg_replace('/.*_/','',$this->api->page);
  295
+
  296
+                $this->columns[$field]['refid']=$refid;
  297
+            }
  298
+        }
  299
+
  300
+
277 301
 		$class=$this->name.'_'.$field.'_expander';
278 302
 		$this->js(true)->_selector('.'.$class)->_load('ui.atk4_expander')->atk4_expander();
279 303
 	}

0 notes on commit 6788f40

Please sign in to comment.
Something went wrong with that request. Please try again.