Draw The Multidimensional Grid View

I dont know how to make the grid view in Yii. So come here to ask about the solution to change the work from the php, html and javascript to yii.

1 - The first thing is about the basic table, which I already made by php and javascript. It simply has 2 dimensions call A and B. So it’s easy to me to create them by some foreach loops method and identify the slot of the tables. With normal php and html, Im able to assign the class name and id number for the table tag, therefore I could use javascript to change the color of the slot, and id number( example: A3B2) helps me to recognize the slot, so I could put the data inside the slot. My question is how to draw this table in Yii, and how to add the attribute: class, id and so on to the tag of the table by Yii. Finally, how can I identify the slot or that means how to find and use these attributes to perform some javascript or change the css by using Yii frame-work.

2- As the second picture shows, you can see that it has another value G. One G has many B, so G–>B. In the first problem I described above, I just have to use an array $slot[$a][$b] and run some loops then all done. But now it’s hard for me to select exactly what the slot is and how to draw them as the picture.

3- If I have another dimension is C, so of course, the slot will have id is slot[a][b][c]. But I dont know how to draw them by neither php or html. Anyone who familiar with that, please give me some ideas to solve it. It could be awesome if the solution is able to run on the yii.

  1. It is not necessary to use Yii’s widget to create your custom table. I’ll use php+html directly; Especially because you don’t have to use built-in controls of Yii CGridView (as filter, sorting, ecc…)

  2. In fact, to make the grouping should you need to identify the B rows that have the same G;

  3. I think that you should select a value for 3rd element of array and then display table;

Just correct my mistake, G has many B, not A. The problem is the table has only 2 tags :tr and td which stand for row and column. Im thinking about draw it with G value as tr tag id and A value as td tag id, should be $slot[g][a] .Then inside this slot, draw a list with ul and value of B for li tag id. Will come back if it works or not :).

If you need to span rows or columns you have colspan or rowspan attributes of td tag.

maybe like this :


Thank mrkoeh, but your solution doesnt suit here. Main point of this topic is how to draw the gridview and add the id for each slot to identify them later. As Fabrizio said, yii dont have built-in CView that allow me to do it, so I have to use php and html directly.

There are some codes that I did and it worked :D:


for ($row=0; $row<$maxrow; $row++)


  <tr id =".$row.">

   for ($column=0; $column<$maxcolumn; $column++)


       $id1= $row."".$column;

       <td id=".$id1.">


            for ($column=0; $list<$maxlist; $list++)


                $id2= $row."".$column."".$list;

                <li id =".id2.">

                 if ($slotid = $id2)

                  echo $slotid;