Is it possible to have a vertical MVC grid?

216 Views Asked by At

I have a MVCgrid with few fields with and expander to view all the detials. Inside the expander, in order to view all the details I use an MVCform without submit action, but it feels weird. Is it possible to have a MVCgrid vertical to show one single record, so I can see all the details, I mean like this:

+-------+-------+------+
| col1  | col2  |expand|
+-------+-------+------+
| data1 | data2 |[view]|
+-------+-------+------+
+-------+-------+
| col1  | data1 |
+-------+-------+
| col2  | data2 |
+-------+-------+
| col3  | data3 |
+-------+-------+
+-------+-------+------+
| data2 | data3 |[view]|
+-------+-------+------+
1

There are 1 best solutions below

5
On BEST ANSWER

Sure, here you go:

$model=$this->add('Model_Alumno')->loadData($_GET['id']);

$data=array();
foreach($model->get() as $key=>$val){
    $row=array[];
    $row['label']=$model->getField($key)->caption();
    $row['val']=$val;
    $data[]=$row;
}
$g=$this->add('Grid');
$g->addColumn('text','label');
$g->addColumn('text','val');
$g->setStaticSource($data);