Pages - Lists

(note: list is the CaseMaster® term form the Bootstrap table)

Lists make up a fair part of all online systems. CaseMaster® offers a number of main variations:

  • List. A simple list with columns, you can optionally click on a row
  • Filtered list. A list with a quick search option
  • Extended filtered list. A filtered list with extended search options
  • Check list. A simple list allowing you to select one or more items and action them
  • Check filtered list. A filtered list allowing you to select one or more items and action them

"Example of lists"

The following code shows the simple list <@page/data/table> qualifier, note the iterator.ofEntity() at the heart of the code, look here for more information.

inherits 'base'

function main()
    page.render(page.get('./main'))
end-function

resource main
    <@page/container
        content: <@page/content
            <@page/data/table
                iterator: iterator.ofEntity(
                    entities: <
                        <
                            name: 'contract'
                            entity: 'prm/contract'
                            orderby: 'name'
                        >
                    >,
                    rows: 2
                )
                group: 'id,name,_status'
            >
        >
    >
end-resource

The <@page/data/table> has a number of tags which are shared by all list variations. The most important tags are:

Tags Usage
tableClass Specifies one or more class names for the table
includeHeader Will a header row be included
headClass Specifies one or more class names for the table head
rowClass Specifies one or more class names for the rows
rowExclude A Boolean flag to state if a row should be exclude
rowBeforeInvoke An expression to be evaluated before each row is invoked
rowLink Specifies a link for a row
responsive Force responsive table (see Bootstrap documentation)
compact Force compact table (see Bootstrap documentation)
bordered Force nordered table (see Bootstrap documentation)
striped Force striped table (see Bootstrap documentation)
rightAlignNumbers Enable right-aligned numerical values (defaults to true())
iterator The iterator containing the data to be listed
group Defines the tables display group
sortable Enable sorting of the table columns
export Enable exporting of the table

Group

The group tag defines which columns are displayed. The simplest version would be something like this:

    group: 'description'

If the iterator has multiple entities, the list will show the description group for each of the entities.

You can optionally prefix each entry in the ad-hoc group with the name of the entity:

    group: 'client:description'

The following is an extended example:

    <@page/data/table
        iterator: iterator.ofEntity(
            entities: <
                <
                    name: 'object'
                    entity: 'om/object'
                    orderBy: 'reference'
                >
                <
                    name: 'location'
                    entity: 'crm/location'
                    orderBy: 'postcode'
                >
            >
        )
        group: 'location:_address,object:description,-object:status'
    >

The rowlink tag defines what happens when a user clicks on a table row. The following is a commonm example:

    rowLink: <@page/table/link
        url: <@url
            address: 'activityStart'
            qs: <
                activity: $bo.pk( [activity] )
            >
        >
    >

Note that the activity tag uses a $-expression (as we have seen with BO dynamic attributes). This makes sense as the expression refers to the entity of the iterator and this is only available at runtime, not when the property bag is retrieved.

The following example is from a system that makes use of the base layer:

    rowLink: <@page/table/link
        url: <@url
            address: 'objectAddSelectObjectGroup'
            qs: <
                relation: $bo.pk( [relation] )
            >
        >
    >

Export

The export tag is used to define whether and how the table data can be exported. The simplest format is as follows:

    export: true()

Or you can allow / disallow exporting based on the users' group:

    export: inGroup( 'ADMIN') 

The export tag can however have a lot more information:

    export: inGroup( 'ADMIN') 

The following shows an extended example:

    export: <@page/data/table/export
        iterator: $bo.invoke(
            'application/data/bo', 
            'list',
            name: 'entity',
            page: 1,
            limit: 9999,
            filter: qs.getUntrusted('filter'),
            attrs: true()
        )
        group: '*'
    >

See the @page/data/table/export for details.

Using RowClass

The rowClass tag can be used to assign a specific class to a row; often based on specific values.

The following example demonstrates how a row will have the text-muted class added when the status equals 3. Notice the $-expression.

    rowClass: $if( eq( bo.attr( [login], 'status' ), 3 ), 'text-muted', null() )

Totallers

Totallers are part of the base-layer and are used to add totals to specific table columns.

    totallers: <
        <@page/data/table/totaller
            attribute: 'linePrice'
        >
    >

See the qualifier @page/data/table/totaller for more information.

Totallers in action

Filtered Lists

Extended Filtered Lists

Check Lists

<End of document>