Views similar to list and detail views in database module.

Views similar to list and detail views in database module.

by Jon Witts -
Number of replies: 12
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi,

I am trying to get my views to behave in a manner similar to how the list and detail views in the Database module did but I ma struggling...

I have followed the steps in this post: https://moodle.org/mod/forum/discuss.php?d=256813 which got it going, but as soon as I go back into my view to edit it the HTML for the table is stripped from the view and entry template...

What am I doing wrong?

Jon

Average of ratings: -
In reply to Jon Witts

Re: Views similar to list and detail views in database module.

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I have created a grid view and I am adding the following for my View template:
<div>
    <div class="exporthide">##viewlink:Single view;Add a new entry;editentries=-1;##</div>
    <table id="custom-horizontal-table" class="generaltable"><theader><th>Author</th><th>Start Date</th><th>End Date</th><th>Reason</th><th>Actions</th></theader><tbody>##entries##</tbody></table>
    <div class="quickfilters-wrapper">
        <div class="quickfilter">Current filter ##filtersmenu##</div>
        <div class="quickfilter">Search ##quicksearch##</div>
        <div class="quickfilter">Per page ##quickperpage##</div>
        <div class="clearfix"></div></div><div>##paging:bar##</div>
    </div>
</div>
and the following for my entry template:
<tr><td>EAU:picture&nbsp;EAU:name</td>
<td>start-date:date</td>
<td>end-date:date</td>
<td>reason</td>
<td>EAC:edit:Single view&nbsp;EAC:more:Single view</td></tr>
Which displays as expected but when editing the view I loose all of the html in teh entry view and the entire table html is stripped too...
Attachment dataform.PNG
In reply to Jon Witts

Re: Views similar to list and detail views in database module.

by Itamar Tzadok -

If you put broken html in the templates, the editor "fixes" it, which in some cases (e.g. broken tables) results in stripping it. That's a Moodle thing, not unique to the Dataform. If you really need to use broken html, you need to turn off the editor whenever editing the templates.

Note that the Dataform offers you two view types which are already designed to display entry content in aligned tables. The Dataformview_Aligned view offers a simplified entry template where you specify in a textarea the patterns per columns. The Dataformview_Tabular view uses an html table in a WYSWIG editor.

Create default instances of these types to see how they work.

hth smile

Average of ratings: Useful (1)
In reply to Itamar Tzadok

Re: Views similar to list and detail views in database module.

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

It was the Tabular View that I needed; thanks Itamar! big grin

Interestingly even with the editor disabled in my profile opening the Grid View for editing would still strip my html.

I had tried to use the Aligned View but could not get that to display headings for my table.

I am more than happy to help contribute to the docs once I have worked it all out myself!

Thanks,
Jon

In reply to Itamar Tzadok

Re: Views similar to list and detail views in database module.

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Still struggling with my HTML tables being stripped in the Tabular View Entry Template.

I have deleted the default table that the view creates and entered my own HTML table to control how I want things laid out for both entry and viewing... I have validated this table and all HTML is correct, yet it still gets stripped out when I come back in to edit even with the HTML editor switched off... 

Any other pointers?

HTML below.

Thanks,
Jon

-------------

<table>
    <caption><h3>Application for Absence from School</h3></caption>
    <tbody>
        <tr>
            <td colspan="4"><strong>Person submitting request:</strong> EAU:firstname [ [EAU:lastname]]</td>
        </tr>
        <tr>
            <td colspan="2">Time added: [ [ETM:timecreated:date]]</td>
            <td colspan="2">Time modified: [ [ETM:timemodified:date]]</td>
        </tr>
        <tr>
            <td colspan="4"><h4>Date(s) of and reason for absence:</h4></td>
        </tr>
        <tr>
            <td colspan="2"><strong>Start:</strong> [ [start-date]]</td>
            <td colspan="2"><strong>End:</strong> [ [end-date]]</td>
        </tr>
        <tr>
            <td colspan="4"><strong>Duration:</strong> [ [am-pm-all-day]]</td>
        </tr>
        <tr>
            <td colspan="4"><strong>Reason for Absence:</strong> [ [reason]]</td>
        </tr>
        <tr>
            <td colspan="4">Please complete the relevant section below based upon your selected reason for absence.</td>
        </tr>
        <tr class="grey">
            <td colspan="4"><h4>Details for INSET, Conferences etc.</h4></td>
        </tr>
        <tr class="grey">
            <td colspan="2"><strong>Title of course:</strong> [ [course-title]]</td>
            <td colspan="2"><strong>Provider:</strong> [ [course-provider]]</td>
        </tr>
        <tr class="grey">
            <td colspan="2"><strong>Venue:</strong> [ [course-venue]]</td>
            <td colspan="2"><strong>Cost of course:</strong> [ [course-cost]]</td>
        </tr>
        <tr class="grey">
            <td colspan="2"><strong>Estimated travel costs:</strong> [ [course-travel]]</td>
            <td colspan="2"><strong>Reason for attending the course:</strong> [ [course-reason]]</td>
        </tr>
        <tr class="grey">
            <td colspan="2"><strong>Proposed source of funding:</strong> [ [course-funding]]</td>
            <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
            <td colspan="4"><h4>Details for School Trips</h4></td>
        </tr>
        <tr>
            <td colspan="4"><strong>Year Group(s):</strong> [ [trips-year]]</td>
        </tr>
        <tr>
            <td colspan="4"><strong>Activity:</strong> [ [trips-activity]]</td>
        </tr>
        <tr class="grey">
            <td colspan="4"><h4>Details for Other reasons</h4></td>
        </tr>
        <tr class="grey">
            <td colspan="4">[ [other-reasons]]</td>
        </tr>
        <tr>
            <td colspan="4"><h4>Cover requirements for teaching periods missed</h4><br>Please note that work should be set and details attached if necessary.</td>
        </tr>
        <tr>
            <td colspan="4"><strong>Cover details</strong> (please state: periods, classes, venue and member of staff to cover lesson<span class="req">*</span>)[ [cover-details]]</td>
        </tr>
        <tr>
            <td colspan="4"><span class="req">*</span> If no member of your department is available to cover please state this.</td>
        </tr>
        <tr>
            <td colspan="4"><strong>File upload for cover details:</strong> [ [cover-file]]</td>
        </tr>
        <tr class="grey">
            <td colspan="4"><strong>Record administration controls</strong></td>
        </tr>
        <tr class="grey">
            <td>Edit: [ [EAC:edit]]</td>
            <td>Delete: [ [EAC:delete]]</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
    </tbody>
</table>
In reply to Jon Witts

Re: Views similar to list and detail views in database module.

by Itamar Tzadok -

On My test environment your template persists.

Do you have html_tidy filter or something else of the sort activated?

When you create a view with the default template without any changes, does that template get stripped?

On a related note,  I think that the entry template you posted is trying to do too much. Typically you would have for the list view one entry per row with just a few details in each entry so that users could see what's there in a glance.

smile

In reply to Itamar Tzadok

Re: Views similar to list and detail views in database module.

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

No html_tidy enabled. See screen grab for all filters enabled...

The HTML in https://moodle.org/mod/forum/discuss.php?d=307555#p1238446 is for the "single template" (in database module terms!); I am trying to use this view for viewing previously entered records in full and for entering them too. I have a far simpler template for list view whose HTML holds fine...

I will upgrade themes and Moodle code to latest on my test environment to see if that helps...

Jon

Attachment filters.PNG
In reply to Jon Witts

Re: Views similar to list and detail views in database module.

by Itamar Tzadok -

For the Single view use the Grid type. Set per page to 1. The default template will generates a table which you can edit. With per page 1, the view will show 1 entry at a time and a paging bar. smile

In reply to Itamar Tzadok

Re: Views similar to list and detail views in database module.

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Still suffering with HTML table being removed upon save and re-edit in that View Template too... Will try the upgrades and test in a few other browsers (I am using Firefox at the moment...)

Jon

In reply to Itamar Tzadok

Re: Views similar to list and detail views in database module.

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

The default template holds its HTML table...

I have tried disabling all text filters in the module except emoticons and links to no effect...

I will try the upgrade now and see where I get to!

Jon

In reply to Jon Witts

Re: Views similar to list and detail views in database module.

by Itamar Tzadok -

Also, see https://moodle.org/mod/forum/discuss.php?d=279033 for how to open entry for viewing or editing in different views. I'll be updating the docs in the next couple of weeks and will post there these explanations and also advanced techniques. smile 

Average of ratings: Useful (1)
In reply to Itamar Tzadok

Re: Views similar to list and detail views in database module.

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Itamar,

I had found this one and have already implemented in my views; very helpful.

Thanks,
Jon