Simple Table

Simple Table is a lightweight component built upon FFTable, offering functionalities for creating complex table headers and footers with ease. Unlike FFTable, it doesn't include a built-in form for editing data, paging and sorting.

Features

Basic Implementation

Include the component in your view:

<f3:inject id="content">
    <div x-data="data" class="max-w-screen-md">
        <include href="blocks/simple-table.html" />
    </div>
</f3:inject>

<f3:inject id="script" mode="append">
    <script src="{{@BASE}}/js/fftable.min.js"></script>
    <script src="{{@BASE}}/js/util.js"></script>
    <script>
        let data = {
            table: {
                fullWidth: true,
                size: 'none',
                display: 'compact',
                containerClass: 'h-[60vh]',
                // Dynamic row styling
                rowClass(idx, row) {
                    return {
                        'whitespace-nowrap': true,
                        'bg-blue-200': idx % 5 == 0
                    };
                },
                // Dynamic cell styling
                cellClass(cidx, ridx, row, col) {
                    return {
                        'bg-red-200': ridx == 5 && cidx == 3,
                        'bg-yellow-200': row[col] > 95,
                    }
                },
                // Column definitions
                columns: [
                    { name: 'city' },
                    { name: 'trousers', class: 'text-right', type: 'number' },
                    { name: 'skirts', class: 'text-right', type: 'number' },
                    { name: 'dresses', class: 'text-right', type: 'number' },
                    { name: 'bracelets', class: 'text-right', type: 'number' },
                    { name: 'rings', class: 'text-right', type: 'number' }
                ],
                // Complex header with merged cells
                customHeader: [
                    [
                        { title: 'City', attr: { rowspan: 2 }, class: 'border-r border-t' },
                        { title: 'Clothes', attr: { colspan: 3 }, class: 'border-r border-t' },
                        { title: 'Accessories', attr: { colspan: 2 }, class: 'border-t' }
                    ],
                    [
                        { title: 'Trousers', class: 'border-r' },
                        { title: 'Skirts', class: 'border-r' },
                        { title: 'Dresses', class: 'border-r' },
                        { title: 'Bracelets', class: 'border-r' },
                        { title: 'Rings' }
                    ]
                ],
                // Footer with calculations
                customFooter: [
                    [
                        { value: 'Total', class: 'font-bold border-r text-center', attr: { rowspan: 2 } },
                        { name: 'total-trousers', class: 'text-right border-r' },
                        { name: 'total-skirts', class: 'text-right border-r' },
                        { name: 'total-dresses', class: 'text-right border-r' },
                        { name: 'total-bracelets', class: 'text-right border-r' },
                        { name: 'total-rings', class: 'text-right' }
                    ]
                ]
            }
        };
    </script>
</f3:inject>

Configuration Options

Table Properties

fullWidth
Make table fill container width
size
Table padding size: 'sm', 'md', 'lg', or 'none'
display
Display style: 'default' or 'compact'
containerClass
CSS classes for the table container
role
ARIA role attributes for accessibility (automatically set)
aria-label
Screen reader description (automatically set to "Data table")

Dynamic Styling

rowClass(idx, row)
Function to return classes for each row
cellClass(cidx, ridx, row, col)
Function to return classes for each cell

Column Configuration

name
Column identifier matching data field
class
CSS classes for the column
type
Data type: 'text', 'number', 'date', etc.

Complex Headers & Footers

customHeader
Array of row arrays for complex headers
customFooter
Array of row arrays for complex footers
title
Header cell content
value
Footer cell static content
name
Footer cell dynamic content from data
attr
HTML attributes (colspan, rowspan)

Best Practices

Accessibility Features

Keyboard Navigation
Rows are focusable using Tab key
ARIA Roles
Semantic table roles for screen readers
Focus States
Visual indicators for keyboard navigation
Screen Reader Support
Proper table structure and labeling

Properties

fullWidth
Boolean, to use full width of container or flow as content width
display
compact|normal specify padding between cells
containerClass
class for container
rowClass
class for row, can be a constant or a function that receive index and data as parameter.
cellClass
class for cell, can be a constant or a function that receive col index, row index, data and col name as parameter.
customHeader
Define non standard table header. If undefined, standard table header created from columns definition.
columns
Data Structure definition for Simple Table
data
data to be rendered. There is special row that has "__customRow" property where we can display anything. Usually when we want to draw separator.
customFooter
Define complex footer
footerData
data for customFooter

Interactive States

Hover
Light highlight on row hover (bg-gray-50 in light mode, bg-gray-600 in dark mode)
Focus
Distinct highlight when row is focused (bg-gray-100 in light mode, bg-gray-500 in dark mode)

See demo here