Inheriting Table Properties

In this chapter we will make the orders3.mql file which inherits properties from orders2.mql file.
We will add the properties that we want to change or add.

On this page:

Setting Permissions

Because we want the new menu to have its own set of permissions we change the value of the FUNZIONE:

<%flags>
inherit => 'orders2.mql'
</%flags>

<%method FUNZIONE>Orders3</%method>

The corresponding menu should have identical demo.orders.nome value:

Orders (3) menu settings.

Adding a Field Method

The resulting demo.orders table contents will be shown by default in a form or consecutive records:

Contents of the orders table.

Note that we added the currency letter besides the price field with:

<%method price_FIELD><& /input/number.comp, %ARGS &>€</%method>

Changing Form

If we want to show the records in a table we can set method FORM_TYPE to TABLE and add a couple of helper methods:

<%method FORM_TYPE>TABLE</%method>
<%method TABLE_ROWS>10</%method>
<%method ORDER>price, id</%method>

It is important that the sorting must be unique, otherwise the cache mechanism will report errors in the sorting of keys in the cache.

The default sorting for method ORDER is by a primary key:

<%method ORDER>order by <& SELF:KEY &></%method>

Here is the resulting table with rows sorted by price column:

Contents of the orders table in the TABLE format.

Other possible FORM_TYPE values, besides TABLE, are LINEAR, DIVS and TEMPLATE. The latter LINEAR and DIVS are used less often. The TEMPLATE type is used in conjunction with FORM_TEMPLATE method.

Topic revision: r9 - 07 Mar 2020, GuidoBrugnara
This site is powered by FoswikiCopyright (©) Leader.IT - Italy P.I. IT01434390223 Privacy policy & use of cookies