How can I list database information horizontally instead of vertically?

How can I list database information horizontally instead of vertically?

by Dean Mattson -
Number of replies: 12
I've been searching for the answer to this question and, if it's been answered, I haven't been able to figure out how to do it.

I want to change one of the database templates so it displays the information horizontally.

It's a weather database and I want the students to be able to analyze the data over several days and that's almost impossible when the information is displayed vertically.

For simplicity's sake, let say the information the students are collecting is the date, the temperature and the barometric pressure. How can I see that information in a horizontal list?
Average of ratings: -
In reply to Dean Mattson

Re: How can I list database information horizontally instead of vertically?

by David Bogner -
Picture of Core developers Picture of Plugin developers
turn off the editor and type following html-source in top section:

<table style=" padding:5px; border-style: none; background-image: none; float: none; text-align: left; vertical-align: top;" border="0" frame="void" rules="none" width="100%">
<tr>

repeated entry type following:

<td>field1</td>
<td style="border-left-width:3px; border-color:black;border-left-style:solid;border-color:red;">field2</td>

in the footer section type following:
</tr>
</table>
Average of ratings: Useful (2)
In reply to David Bogner

Re: How can I list database information horizontally instead of vertically?

by Dean Mattson -
Thanks for the help. I was able to do what I wanted because of your expertise.

For anyone as inexperienced as I as and want to use the above as a model, I did have to add:

</tr>

in the repeated entry section to get it to work right.

Have some reading and experimenting, I put this in the top section:

<table style=" padding:5px; border-style: none; background-image: none; float: none; text-align: left; vertical-align: top;" border="0" frame="void" rules="none" width="100%">
<tr><TH colspan="1">field1
<TH colspan="1">field2
<tr>

This gave me some column headers. I'm not sure if that's the right way to do it, but it seems to be working!

Thanks again.
In reply to David Bogner

Re: How can I list database information horizontally instead of vertically?

by Eva Lacy -

I have a database that desperately needs to be displayed horizontally and I tried the two suggestions but without success. Could you explain it again, maybe in really simple absolute coding novice language?

I really appreaciate any help that's out there.

In reply to Eva Lacy

Re: How can I list database information horizontally instead of vertically?

by Liz Cross -

In the template for List View create a table for the headings and a table for the data (see attached).  The only additional thing I did was to go into the HTML code and change the percentages for the column widths so that coresponding columns were the same widths in the headings table and the data table. I have attached a screenshot and also an example database for you to try out in moodle - hope this helps.

In reply to Liz Cross

Re: How can I list database information horizontally instead of vertically?

by dan roggenkamp -
And that works just fine, but here's one more question. How does the Moodle site, in their horizontally displayed database list views, get the name field to link to what I'm assuming is the ##more## link in the default template? I'm sure it's probably something very simple, and if past experience is any indicator, I will probably have found the answer before I get a response... but that trick only works if I ask the question!
In reply to dan roggenkamp

Re: How can I list database information horizontally instead of vertically?

by dan roggenkamp -
Yes, I should have RTFM first. The answer is clearly documented at http://docs.moodle.org/en/Database_templates#List_template which states:
  • ##moreurl## creates just the URL for the above link, useful for creating your own links. You can click on the link icon and type ##moreurl## into URL field or in source view type <a href="##moreurl##">fieldname</a>.
There's a lot of good documentation there, by golly.
In reply to David Bogner

Listing database information horizontally instead of vertically?

by Peter Evans -

After you have created the fields in the database click

> TEMPLATES

> LIST TEMPLATES

> and enter the following into the HEADER in HTML mode

<table style=" padding:5px; background-image: none; float: none; text-align: left; vertical-align: top; border-collapse:collapse" border="2" frame="void" rules="none" width="100%" bordercolorlight="#000000" bordercolordark="#000000" cellpadding="5">
<tr>
<TH colspan="1">Date
<TH colspan="1">Time (start-end)
<TH colspan="1">Contact (Name & extension)
<TH colspan="1">Purpose
<TH colspan="1">Edit
</tr>


> enter the following into the REPEATED ENTRY in HTML mode

<tr>
<td>
Date
</td>

<td>
Time (start-end)
</td>

<td>
Contact (Name & extension)
</td>

<td>
Purpose
</td>

<td>
##edit## ##more## ##delete## ##approve##
</td>

</tr>


Enter the following into the Footer in HTML mode

</table>


> click SAVE TEMPLATES

> click VIEW LIST

If all is well in the universe you should now see your database listed with each entry in a single row.

A screen image is attached and you can see the functioning database at http://www.baker-evans.com/community/mod/data/view.php?d=5 

Unfortunately if you edit the template a filter in Moodle will validate the code and muck it up but if you keep the code in a external document you can just paste it back in and all will be well.

Does anyone know how or where to turn this off.

Peter Evans

 

Attachment horizontal_db.gif
Average of ratings: Useful (1)
In reply to Peter Evans

Re: Listing database content horizontally instead of vertically

by Robert Allerstorfer -
Peter Evans:
"Unfortunately if you edit the template a filter in Moodle will validate the code and muck it up but if you keep the code in a external document you can just paste it back in and all will be well. Does anyone know how or where to turn this off."

Hi Peter,

the first thing you should always do when entering one of the templates pages is to press the "Disable editor" button (unless the HTML WYSIWYG editor - which is really a bad thing there - is already disabled).

Best practice is to have a development instance of the same Moodle version, where you maintain a copy of the life database activity. Do all modifications of HTML templates always within a real good HTML editor app - and never directly in Moodle's interface. When you are finished, just select the entire text in your external editor app, copy & paste it into the corresponding field of Moodle's template pages. Finally, press the "Save template" button to make the changes effective.

Everytime you have changed something of the templates or fields, I would advise to go to the "Presets" tab and export as zip.

In your life Moodle, import the preset zip you have exported from the development instance.

Note that this process only works well as of the current 1.9.1+ weekly snapshot.

Best regards,
Robert

In reply to Robert Allerstorfer

Re: Listing database content horizontally instead of vertically

by Madhu Avasarala -

Good day all,

My aim is to get the most recently added items to be highlighted for attention after being listed vertically. I managed to get the vertical listing to work after following the instructions on this thread. Can someone point me the way to get the highlighting to work?

Thanks


Madhu

In reply to Peter Evans

Re: Listing database information horizontally instead of vertically?

by Itamar Tzadok -

Unfortunately if you edit the template a filter in Moodle will validate the code and muck it up but if you keep the code in a external document you can just paste it back in and all will be well.

Does anyone know how or where to turn this off.

One way to avoid this unfortunate but sometimes necessary behavior is to write the table with javascript. In the header you define a string variable to which you then add the relevant table parts from each section of the template and finally document.write it in the template footer. Something like:

Header script:

var strHtml="";
strHtml+='..'; // open table and header row

Body script:

strHtml+='..'; // data row; the template generator do the loop on this script command and you get all rows.

Footer script:

strHtml+='..'; // close table
document.write(strHtml);

In reply to Peter Evans

回應: Listing database information horizontally instead of vertically?

by Anderson Hsu -
In reply to Anderson Hsu

Re: 回應: Listing database information horizontally instead of vertically?

by William Lu -
Picture of Particularly helpful Moodlers

Hi Anderson,

When you are following Peter's guide, make sure you have clicked on the 'Disable Editor' button once.

d