Add double header in html_table

Add double header in html_table

by Luiz Henrique Salazar -
Number of replies: 1

I'm struggling in figuring out how to add a double header using html_table. My main goal is to add two <tr> into <thead>. However, I guess the API does not support this kind of header. I've tried using something like that:

        $table = new html_table();

        $table->attributes['class'] = "relatorio-unasus $this->report_name generaltable";

        $blank = new html_table_cell();

        $blank->attributes = array('class' => 'blank');

        $student = new html_table_cell("Estudantes");

        $student->header = true;

        $student->attributes = array('class' => 'ultima_atividade title estudante');

        $heading1 = array(); // First Line

        $heading1[] = $blank; 

        $heading2 = array(); // Second line

        $heading2[] = $student;

        ....

And when I tried to add $heading1 and $heading2 to the table header using:

        $this->head

It just adds one of the two lines I inserted. Otherwise, if I insert into table $data through:

        $this->data[] = new html_table_row($heading1);

        $this->data[] = new html_table_row($heading2);

all works fine.

Although, what I need is to freeze the header through the <thead> tag and if I inserted these header data as data I can't do that!

Anyone has any idea how to solve this question? I mean, some way to add two lines into a table header through the html_table API.


Thanks.






Average of ratings: -
In reply to Luiz Henrique Salazar

Re: Add double header in html_table

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Luiz,

If this is not what you wanted, then sorry, I misunderstand. But, if I understand correctly, you want to make a table in a forum entry that looks something like this:


Table Example
First line
Second Line
First Line
Second Line
First Line
Second Line
First Line
Second Line
Row 2 column 2 Row 2 column 3
First Line
Second Line
Row 3 column 2 Row 3 column 3

All I did was make the table, then click on the HTML toggle button. I then added a break in front of the text for each of the places I wanted a second line in the column and row headings. Here is a picture of what I added.