Morten Sæther

← Blog

Advanced List Features

#14 · 13 May 2026

Filtering, custom columns, export, and bulk actions on real data volumes

A basic list shows data. An advanced one lets people find things, compare them, export them and act on twenty at once - which is the difference between a portal people tolerate and one they open every morning.

The catch is that everything here gets harder as the dataset grows. Techniques that feel fine against fifty records fall apart at fifty thousand, so most of this post is about doing the work on the server rather than in the browser.

Step by step

1. Build a real filter interface

Multiple criteria, date ranges, text search, all at once:

<!-- Advanced List Filter Component -->
<div class="advanced-list-container" id="customerListContainer">
    <!-- Filter Panel -->
    <div class="list-filters-panel" id="filtersPanel">
        <div class="filters-header">
            <h3>Filters</h3>
            <div class="filter-actions">
                <button type="button" class="btn btn-outline-secondary btn-sm" id="clearFilters">
                    Clear All
                </button>
                <button type="button" class="btn btn-outline-secondary btn-sm" id="saveFilterSet">
                    Save Filter Set
                </button>
                <button type="button" class="btn btn-outline-secondary btn-sm" id="toggleFilters">
                    <span class="filter-toggle-icon">▼</span>
                </button>
            </div>
        </div>
        
        <div class="filters-content" id="filtersContent">
            <!-- Text Search -->
            <div class="filter-group">
                <label for="searchText">Search</label>
                <div class="search-input-wrapper">
                    <input type="text" id="searchText" name="searchText" 
                           placeholder="Search customers..." class="search-input">
                    <button type="button" class="search-btn" id="searchBtn">🔍</button>
                </div>
            </div>
            
            <!-- Status Filter -->
            <div class="filter-group">
                <label for="statusFilter">Status</label>
                <select id="statusFilter" name="statusFilter" class="filter-select" multiple>
                    <option value="1">Active</option>
                    <option value="2">Inactive</option>
                </select>
            </div>
            
            <!-- Date Range Filter -->
            <div class="filter-group">
                <label>Registration Date</label>
                <div class="date-range-inputs">
                    <input type="date" id="dateFrom" name="dateFrom" class="date-input" 
                           placeholder="From">
                    <span class="date-separator">to</span>
                    <input type="date" id="dateTo" name="dateTo" class="date-input" 
                           placeholder="To">
                </div>
            </div>
            
            <!-- Category Filter -->
            <div class="filter-group">
                <label for="categoryFilter">Category</label>
                <div class="checkbox-group" id="categoryCheckboxes">
                    <label class="checkbox-item">
                        <input type="checkbox" name="category" value="1">
                        <span class="checkmark"></span>
                        Preferred Customer
                    </label>
                    <label class="checkbox-item">
                        <input type="checkbox" name="category" value="2">
                        <span class="checkmark"></span>
                        Standard
                    </label>
                </div>
            </div>
            
            <!-- Value Range Filter -->
            <div class="filter-group">
                <label for="valueRange">Annual Value</label>
                <div class="range-slider-container">
                    <input type="range" id="valueRangeMin" min="0" max="1000000" value="0" 
                           class="range-slider">
                    <input type="range" id="valueRangeMax" min="0" max="1000000" value="1000000" 
                           class="range-slider">
                    <div class="range-values">
                        <span id="valueRangeMinDisplay">$0</span>
                        <span id="valueRangeMaxDisplay">$1,000,000+</span>
                    </div>
                </div>
            </div>
            
            <!-- Custom Field Filters -->
            <div class="filter-group">
                <label>Custom Filters</label>
                <div class="custom-filter-builder" id="customFilterBuilder">
                    <div class="custom-filter-row">
                        <select class="filter-field-select">
                            <option value="">Select field...</option>
                            <option value="industry">Industry</option>
                            <option value="region">Region</option>
                            <option value="employeeCount">Employee Count</option>
                            <option value="revenue">Annual Revenue</option>
                        </select>
                        <select class="filter-operator-select">
                            <option value="equals">Equals</option>
                            <option value="contains">Contains</option>
                            <option value="startsWith">Starts with</option>
                            <option value="greaterThan">Greater than</option>
                            <option value="lessThan">Less than</option>
                        </select>
                        <input type="text" class="filter-value-input" placeholder="Value">
                        <button type="button" class="btn-remove-filter">✕</button>
                    </div>
                    <button type="button" class="btn btn-outline-secondary btn-sm" id="addCustomFilter">
                        + Add Filter
                    </button>
                </div>
            </div>
        </div>
    </div>
    
    <!-- List Controls -->
    <div class="list-controls">
        <div class="list-controls-left">
            <div class="results-info">
                <span id="resultsCount">Loading...</span>
            </div>
            <div class="view-options">
                <label for="pageSize">Show:</label>
                <select id="pageSize" class="page-size-select">
                    <option value="10">10</option>
                    <option value="25" selected>25</option>
                    <option value="50">50</option>
                    <option value="100">100</option>
                </select>
                <span>per page</span>
            </div>
        </div>
        
        <div class="list-controls-right">
            <div class="column-selector">
                <button type="button" class="btn btn-outline-secondary btn-sm" id="columnSelector">
                    📋 Columns
                </button>
            </div>
            <div class="export-options">
                <div class="dropdown">
                    <button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" 
                            id="exportDropdown">
                        📤 Export
                    </button>
                    <div class="dropdown-menu" id="exportMenu">
                        <a href="#" class="dropdown-item" data-format="csv">
                            📄 CSV
                        </a>
                    </div>
                </div>
            </div>
            <div class="bulk-actions">
                <button type="button" class="btn btn-outline-secondary btn-sm" id="bulkActions" disabled>
                    ⚡ Actions
                </button>
            </div>
        </div>
    </div>
    
    <!-- List Table -->
    <div class="list-table-container">
        <table class="advanced-list-table" id="customerTable">
            <thead>
                <tr>
                    <th class="select-column">
                        <input type="checkbox" id="selectAll" class="select-all-checkbox">
                    </th>
                    <th class="sortable" data-column="name">
                        <span class="column-header">Customer Name</span>
                        <span class="sort-indicator" data-direction="none">⇅</span>
                    </th>
                    <th class="sortable" data-column="emailaddress1">
                        <span class="column-header">Email</span>
                        <span class="sort-indicator" data-direction="none">⇅</span>
                    </th>
                    <th class="sortable" data-column="statuscode">
                        <span class="column-header">Status</span>
                        <span class="sort-indicator" data-direction="none">⇅</span>
                    </th>
                    <th class="sortable" data-column="createdon">
                        <span class="column-header">Registration Date</span>
                        <span class="sort-indicator" data-direction="none">⇅</span>
                    </th>
                    <th class="sortable" data-column="revenue">
                        <span class="column-header">Annual Value</span>
                        <span class="sort-indicator" data-direction="none">⇅</span>
                    </th>
                    <th class="actions-column">Actions</th>
                </tr>
            </thead>
            <tbody id="customerTableBody">
                <!-- Data rows will be populated here -->
            </tbody>
        </table>
        
        <!-- Loading State -->
        <div class="list-loading" id="listLoading" style="display: none;">
            <div class="loading-spinner"></div>
            <p>Loading data...</p>
        </div>
        
        <!-- Empty State -->
        <div class="list-empty" id="listEmpty" style="display: none;">
            <div class="empty-icon">📊</div>
            <h4>No results found</h4>
            <p>Try adjusting your filters or search criteria</p>
            <button type="button" class="btn btn-primary" id="clearFiltersEmpty">
                Clear All Filters
            </button>
        </div>
    </div>
    
    <!-- Pagination -->
    <div class="list-pagination" id="listPagination">
        <div class="pagination-info">
            <span id="paginationInfo">Loading...</span>
        </div>
        <div class="pagination-controls">
            <button type="button" class="btn btn-outline-secondary btn-sm" id="firstPage" disabled>
                ⏮️ First
            </button>
            <button type="button" class="btn btn-outline-secondary btn-sm" id="prevPage" disabled>
                ⬅️ Previous
            </button>
            <button type="button" class="btn btn-outline-secondary btn-sm" id="nextPage">
                Next ➡️
            </button>
        </div>
    </div>
</div>

2. Drive it from the client

The controller that ties filtering, sorting, paging and selection together. It reads accounts through the Power Pages Web API (/_api/accounts), sends the request as FetchXML so the filter, sort and page all run in Dataverse, and includes the __RequestVerificationToken header that every Web API call needs. Table permissions decide what each visitor gets back, so the browser never has to be trusted with that:

class AdvancedListController {
    constructor(containerId, options = {}) {
        this.container = document.getElementById(containerId);
        this.options = {
            entitySet: 'accounts',
            entityName: 'account',
            idColumn: 'accountid',
            pageSize: 25,
            defaultSort: { column: 'name', direction: 'asc' },
            ...options
        };

        this.state = {
            currentPage: 1,
            pageSize: this.options.pageSize,
            records: [],
            filters: {},
            sortColumn: this.options.defaultSort.column,
            sortDirection: this.options.defaultSort.direction,
            selectedRows: new Set()
        };

        this.statusLabels = { 1: 'Active', 2: 'Inactive' };

        this.columns = [
            { key: 'name' },
            {
                key: 'emailaddress1',
                render: (cell, value) => {
                    if (!value) return;
                    const link = document.createElement('a');
                    link.href = `mailto:${value}`;
                    link.className = 'email-link';
                    link.textContent = value;
                    cell.appendChild(link);
                }
            },
            {
                key: 'statuscode',
                render: (cell, value) => {
                    const badge = document.createElement('span');
                    badge.className = value === 1 ? 'status-badge status-active' : 'status-badge status-inactive';
                    badge.textContent = this.statusLabels[value] || '';
                    cell.appendChild(badge);
                }
            },
            { key: 'createdon', format: value => this.formatDate(value) },
            { key: 'revenue', format: value => this.formatCurrency(value) }
        ];

        this.initializeList();
        this.setupEventListeners();
        this.loadData();
    }

    initializeList() {
        this.table = this.container.querySelector('#customerTable');
        this.tableBody = this.container.querySelector('#customerTableBody');
        this.filtersContent = this.container.querySelector('#filtersContent');
        this.loadingElement = this.container.querySelector('#listLoading');
        this.emptyElement = this.container.querySelector('#listEmpty');
    }

    setupEventListeners() {
        this.setupFilterListeners();
        this.setupSortingListeners();
        this.setupPaginationListeners();
        this.setupSelectionListeners();
        this.setupExportListeners();
    }

    setupFilterListeners() {
        // Text search with debouncing
        const searchInput = this.container.querySelector('#searchText');
        let searchTimeout;

        searchInput.addEventListener('input', (e) => {
            clearTimeout(searchTimeout);
            searchTimeout = setTimeout(() => this.updateFilter('search', e.target.value.trim()), 500);
        });
        this.container.querySelector('#searchBtn').addEventListener('click', () => {
            clearTimeout(searchTimeout);
            this.updateFilter('search', searchInput.value.trim());
        });

        // Status filter (statuscode values)
        this.container.querySelector('#statusFilter').addEventListener('change', (e) => {
            const selected = Array.from(e.target.selectedOptions).map(option => option.value);
            this.updateFilter('status', selected);
        });

        // Date range filters
        this.container.querySelector('#dateFrom').addEventListener('change', (e) => {
            this.updateFilter('dateFrom', e.target.value);
        });
        this.container.querySelector('#dateTo').addEventListener('change', (e) => {
            this.updateFilter('dateTo', e.target.value);
        });

        // Category checkboxes (accountcategorycode values)
        const categoryCheckboxes = this.container.querySelectorAll('input[name="category"]');
        categoryCheckboxes.forEach(checkbox => {
            checkbox.addEventListener('change', () => {
                const selected = Array.from(categoryCheckboxes)
                    .filter(cb => cb.checked)
                    .map(cb => cb.value);
                this.updateFilter('categories', selected);
            });
        });

        this.setupRangeSliders();

        // Clear filters
        this.container.querySelector('#clearFilters').addEventListener('click', () => this.clearAllFilters());
        this.container.querySelector('#clearFiltersEmpty').addEventListener('click', () => this.clearAllFilters());

        // Collapse the filter panel
        this.container.querySelector('#toggleFilters').addEventListener('click', () => {
            this.filtersContent.hidden = !this.filtersContent.hidden;
        });
    }

    setupRangeSliders() {
        const minSlider = this.container.querySelector('#valueRangeMin');
        const maxSlider = this.container.querySelector('#valueRangeMax');
        const minDisplay = this.container.querySelector('#valueRangeMinDisplay');
        const maxDisplay = this.container.querySelector('#valueRangeMaxDisplay');

        const updateDisplay = () => {
            minDisplay.textContent = this.formatCurrency(parseInt(minSlider.value, 10));
            maxDisplay.textContent = parseInt(maxSlider.value, 10) >= 1000000
                ? '$1,000,000+'
                : this.formatCurrency(parseInt(maxSlider.value, 10));
        };

        const applyRange = () => {
            this.updateFilter('valueRange', {
                min: parseInt(minSlider.value, 10),
                max: parseInt(maxSlider.value, 10)
            });
        };

        [minSlider, maxSlider].forEach(slider => {
            slider.addEventListener('input', updateDisplay);
            slider.addEventListener('change', applyRange); // query on release, not on every pixel
        });
    }

    setupSortingListeners() {
        this.container.querySelectorAll('.sortable').forEach(header => {
            header.addEventListener('click', () => this.toggleSort(header.dataset.column));
        });
    }

    toggleSort(column) {
        if (this.state.sortColumn === column) {
            this.state.sortDirection = this.state.sortDirection === 'asc' ? 'desc' : 'asc';
        } else {
            this.state.sortColumn = column;
            this.state.sortDirection = 'asc';
        }

        this.container.querySelectorAll('.sortable').forEach(header => {
            const indicator = header.querySelector('.sort-indicator');
            indicator.dataset.direction = header.dataset.column === column ? this.state.sortDirection : 'none';
        });

        this.goToPage(1);
    }

    setupPaginationListeners() {
        this.container.querySelector('#firstPage').addEventListener('click', () => this.goToPage(1));
        this.container.querySelector('#prevPage').addEventListener('click', () => this.goToPage(this.state.currentPage - 1));
        this.container.querySelector('#nextPage').addEventListener('click', () => this.goToPage(this.state.currentPage + 1));
        this.container.querySelector('#pageSize').addEventListener('change', (e) => {
            this.state.pageSize = parseInt(e.target.value, 10);
            this.goToPage(1);
        });
    }

    goToPage(page) {
        if (page < 1) return;
        this.state.currentPage = page;
        this.loadData();
    }

    setupSelectionListeners() {
        this.container.querySelector('#selectAll').addEventListener('change', (e) => {
            this.container.querySelectorAll('.row-checkbox').forEach(cb => {
                cb.checked = e.target.checked;
                if (e.target.checked) {
                    this.state.selectedRows.add(cb.value);
                } else {
                    this.state.selectedRows.delete(cb.value);
                }
            });
            this.updateSelectionState();
        });
    }

    updateSelectionState() {
        const boxes = Array.from(this.container.querySelectorAll('.row-checkbox'));
        const selectAll = this.container.querySelector('#selectAll');
        selectAll.checked = boxes.length > 0 && boxes.every(cb => cb.checked);
        selectAll.indeterminate = !selectAll.checked && boxes.some(cb => cb.checked);
        this.container.querySelector('#bulkActions').disabled = this.state.selectedRows.size === 0;
    }

    setupExportListeners() {
        const menu = this.container.querySelector('#exportMenu');

        this.container.querySelector('#exportDropdown').addEventListener('click', (e) => {
            e.stopPropagation();
            menu.classList.toggle('show');
        });
        document.addEventListener('click', () => menu.classList.remove('show'));

        menu.querySelector('[data-format="csv"]').addEventListener('click', (e) => {
            e.preventDefault();
            this.exportCsv();
        });
    }

    // --- Web API ---

    getToken() {
        return new Promise((resolve, reject) => {
            shell.getTokenDeferred().done(resolve).fail(reject);
        });
    }

    async webApiGet(url) {
        const token = await this.getToken();
        const response = await fetch(url, {
            headers: {
                'Accept': 'application/json',
                '__RequestVerificationToken': token
            }
        });
        if (!response.ok) throw new Error(`Web API returned ${response.status}`);
        return response.json();
    }

    buildFetchXml() {
        const f = this.state.filters;
        const xml = value => String(value)
            .replace(/&/g, '&amp;')
            .replace(/</g, '&lt;')
            .replace(/"/g, '&quot;');
        const conditions = [];

        if (f.search) {
            const term = `%${xml(f.search)}%`;
            conditions.push(
                `<filter type="or">` +
                `<condition attribute="name" operator="like" value="${term}" />` +
                `<condition attribute="emailaddress1" operator="like" value="${term}" />` +
                `</filter>`
            );
        }
        if (f.status && f.status.length) {
            const values = f.status.map(v => `<value>${Number(v)}</value>`).join('');
            conditions.push(`<condition attribute="statuscode" operator="in">${values}</condition>`);
        }
        if (f.dateFrom) {
            conditions.push(`<condition attribute="createdon" operator="on-or-after" value="${xml(f.dateFrom)}" />`);
        }
        if (f.dateTo) {
            conditions.push(`<condition attribute="createdon" operator="on-or-before" value="${xml(f.dateTo)}" />`);
        }
        if (f.categories && f.categories.length) {
            const values = f.categories.map(v => `<value>${Number(v)}</value>`).join('');
            conditions.push(`<condition attribute="accountcategorycode" operator="in">${values}</condition>`);
        }
        if (f.valueRange) {
            conditions.push(`<condition attribute="revenue" operator="ge" value="${Number(f.valueRange.min)}" />`);
            if (f.valueRange.max < 1000000) {
                conditions.push(`<condition attribute="revenue" operator="le" value="${Number(f.valueRange.max)}" />`);
            }
        }

        const attributes = [this.options.idColumn, ...this.columns.map(c => c.key)]
            .map(name => `<attribute name="${name}" />`)
            .join('');
        const order = `<order attribute="${this.state.sortColumn}" descending="${this.state.sortDirection === 'desc'}" />`;
        const filter = conditions.length ? `<filter type="and">${conditions.join('')}</filter>` : '';

        return `<fetch count="${this.state.pageSize}" page="${this.state.currentPage}">` +
            `<entity name="${this.options.entityName}">${attributes}${order}${filter}</entity>` +
            `</fetch>`;
    }

    async loadData() {
        this.showLoading(true);

        try {
            const url = `/_api/${this.options.entitySet}?fetchXml=${encodeURIComponent(this.buildFetchXml())}`;
            const data = await this.webApiGet(url);

            this.state.records = data.value;
            this.renderTable(data.value);
            this.renderPagination(data.value.length);
        } catch (error) {
            console.error('Error loading data:', error);
            this.showError('Failed to load data. Please try again.');
        } finally {
            this.showLoading(false);
        }
    }

    // --- Rendering ---

    renderTable(records) {
        this.tableBody.replaceChildren();
        this.showEmpty(records.length === 0);

        records.forEach(record => {
            const id = record[this.options.idColumn];
            const row = document.createElement('tr');
            row.className = 'list-row';
            row.dataset.id = id;

            const selectCell = row.insertCell();
            selectCell.className = 'select-column';
            const checkbox = document.createElement('input');
            checkbox.type = 'checkbox';
            checkbox.className = 'row-checkbox';
            checkbox.value = id;
            checkbox.checked = this.state.selectedRows.has(id);
            checkbox.addEventListener('change', () => {
                if (checkbox.checked) {
                    this.state.selectedRows.add(id);
                } else {
                    this.state.selectedRows.delete(id);
                }
                this.updateSelectionState();
            });
            selectCell.appendChild(checkbox);

            this.columns.forEach(column => {
                const cell = row.insertCell();
                cell.className = 'data-column';
                cell.dataset.column = column.key;
                const value = record[column.key];
                if (column.render) {
                    column.render(cell, value, record);
                } else {
                    cell.textContent = column.format ? column.format(value) : (value ?? '');
                }
            });

            const actionsCell = row.insertCell();
            actionsCell.className = 'actions-column';
            const view = document.createElement('a');
            view.className = 'btn btn-outline-primary btn-sm';
            view.href = `/customers/details/?id=${encodeURIComponent(id)}`;
            view.textContent = 'View';
            actionsCell.appendChild(view);

            this.tableBody.appendChild(row);
        });

        this.updateSelectionState();
    }

    renderPagination(rowsOnPage) {
        const { currentPage, pageSize } = this.state;
        const first = (currentPage - 1) * pageSize + 1;

        this.container.querySelector('#firstPage').disabled = currentPage === 1;
        this.container.querySelector('#prevPage').disabled = currentPage === 1;
        this.container.querySelector('#nextPage').disabled = rowsOnPage < pageSize;

        const info = rowsOnPage === 0
            ? 'No results'
            : `Page ${currentPage}: rows ${first}-${first + rowsOnPage - 1}`;
        this.container.querySelector('#paginationInfo').textContent = info;
        this.container.querySelector('#resultsCount').textContent = `${rowsOnPage} on this page`;
    }

    formatDate(value) {
        if (!value) return '';
        return new Date(value).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' });
    }

    formatCurrency(value) {
        if (value === null || value === undefined) return '';
        return new Intl.NumberFormat('en-US', {
            style: 'currency',
            currency: 'USD',
            minimumFractionDigits: 0,
            maximumFractionDigits: 0
        }).format(value);
    }

    // --- Export (selected rows, or the current page if nothing is selected) ---

    exportCsv() {
        const rows = this.state.records.filter(r =>
            this.state.selectedRows.size === 0 || this.state.selectedRows.has(r[this.options.idColumn])
        );
        const keys = this.columns.map(c => c.key);
        const cell = value => `"${String(value ?? '').replace(/"/g, '""')}"`;
        const lines = [keys.join(',')].concat(rows.map(r =>
            keys.map(k => cell(k === 'statuscode' ? this.statusLabels[r[k]] : r[k])).join(',')
        ));

        const url = URL.createObjectURL(new Blob([lines.join('\n')], { type: 'text/csv' }));
        const a = document.createElement('a');
        a.href = url;
        a.download = `customers_${new Date().toISOString().slice(0, 10)}.csv`;
        a.click();
        URL.revokeObjectURL(url);
    }

    // --- Filters and state ---

    updateFilter(key, value) {
        if (value === '' || value === null || (Array.isArray(value) && value.length === 0)) {
            delete this.state.filters[key];
        } else {
            this.state.filters[key] = value;
        }
        this.goToPage(1);
    }

    clearAllFilters() {
        this.state.filters = {};

        this.container.querySelector('#searchText').value = '';
        this.container.querySelector('#statusFilter').selectedIndex = -1;
        this.container.querySelector('#dateFrom').value = '';
        this.container.querySelector('#dateTo').value = '';
        this.container.querySelectorAll('input[name="category"]').forEach(cb => { cb.checked = false; });
        this.container.querySelector('#valueRangeMin').value = 0;
        this.container.querySelector('#valueRangeMax').value = 1000000;
        this.container.querySelector('#valueRangeMinDisplay').textContent = '$0';
        this.container.querySelector('#valueRangeMaxDisplay').textContent = '$1,000,000+';

        this.goToPage(1);
    }

    showLoading(show) {
        this.loadingElement.style.display = show ? 'flex' : 'none';
        const hasRows = this.state.records.length > 0;
        this.table.style.display = show || !hasRows ? 'none' : 'table';
    }

    showEmpty(show) {
        this.emptyElement.style.display = show ? 'flex' : 'none';
        this.table.style.display = show ? 'none' : 'table';
    }

    showError(message) {
        this.container.querySelector('#resultsCount').textContent = message;
    }
}

new AdvancedListController('customerListContainer');

Debounce the text inputs. Firing a query on every keystroke is how you take down your own portal.

The example leaves out the total record count (so there is no “Last” button), the column chooser, saved filter sets and the custom filter builder; the markup for those is there, the wiring is not.

3. Make it look like a tool

/* Advanced List Styling */
.advanced-list-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.list-filters-panel {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.filters-header h3 {
    margin: 0;
    color: #495057;
    font-size: 1.1rem;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

.filters-content {
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #495057;
}

.search-input-wrapper {
    position: relative;
    display: flex;
}

.search-input {
    flex: 1;
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.875rem;
}

.search-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
}

.filter-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.875rem;
}

.date-range-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.875rem;
}

.date-separator {
    color: #6c757d;
    font-size: 0.875rem;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.checkbox-item input[type="checkbox"] {
    margin: 0;
}

.range-slider-container {
    position: relative;
}

.range-slider {
    width: 100%;
    margin: 0.5rem 0;
}

.range-values {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #6c757d;
}

.list-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: white;
    border-bottom: 1px solid #e9ecef;
}

.list-controls-left,
.list-controls-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.results-info {
    font-size: 0.875rem;
    color: #6c757d;
}

.view-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.page-size-select {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.875rem;
}

.dropdown {
    position: relative;
}

.dropdown-toggle {
    position: relative;
}

.dropdown-toggle::after {
    content: '▼';
    margin-left: 0.5rem;
    font-size: 0.75rem;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 150px;
    z-index: 1000;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: #212529;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
}

.dropdown-item:hover {
    background: #f8f9fa;
    color: #212529;
}

.list-table-container {
    position: relative;
    overflow-x: auto;
}

.advanced-list-table {
    width: 100%;
    border-collapse: collapse;
}

.advanced-list-table th,
.advanced-list-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.advanced-list-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.875rem;
    color: #495057;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.sortable:hover {
    background: #e9ecef;
}

.column-header {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-indicator {
    opacity: 0.5;
    font-size: 0.75rem;
    transition: opacity 0.2s ease;
}

.sortable:hover .sort-indicator,
.sort-indicator[data-direction="asc"],
.sort-indicator[data-direction="desc"] {
    opacity: 1;
}

.sort-indicator[data-direction="asc"]::before {
    content: '▲';
}

.sort-indicator[data-direction="desc"]::before {
    content: '▼';
}

.select-column {
    width: 40px;
}

.actions-column {
    width: 120px;
}

.list-row:hover {
    background: #f8f9fa;
}

.list-row.selected {
    background: #e7f3ff;
}

.row-actions {
    display: flex;
    gap: 0.5rem;
}

.customer-info {
    display: flex;
    flex-direction: column;
}

.customer-name {
    font-weight: 600;
    color: #212529;
}

.customer-company {
    font-size: 0.75rem;
    color: #6c757d;
}

.email-link {
    color: var(--primary-color);
    text-decoration: none;
}

.email-link:hover {
    text-decoration: underline;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-suspended {
    background: #e2e3e5;
    color: #383d41;
}

.list-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: #6c757d;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e9ecef;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: #6c757d;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.list-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-numbers {
    display: flex;
    gap: 0.25rem;
}

.page-number {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e9ecef;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.page-number:hover {
    background: #f8f9fa;
    border-color: var(--primary-color);
}

.page-number.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

What this looks like in practice

The list above is the whole read path: the Web API applies the visitor’s table permissions, FetchXML does the filtering and paging, the browser only renders. What doesn’t fit that path is the heavy export, where someone wants ten thousand rows as a file. For that I use a cloud flow with the “When Power Pages calls a flow” trigger, added to the site under Set up > Cloud flows and secured with a web role. The site generates a URL for it, and the call is a POST with a JSON body whose property names match the flow’s input parameters:

function requestExport(format) {
    return new Promise((resolve, reject) => {
        shell.getTokenDeferred().done(token => {
            fetch('/_api/cloudflow/v1.0/trigger/00000000-0000-0000-0000-000000000000', {
                method: 'POST',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json',
                    '__RequestVerificationToken': token
                },
                body: JSON.stringify({ Format: format })
            })
            .then(response => response.ok ? resolve(response) : reject(new Error(`Flow returned ${response.status}`)))
            .catch(reject);
        }).fail(reject);
    });
}

The flow takes one Text input, Format, queries Dataverse itself and returns a link to the file in its Response action. Two things to get right here. The flow runs with its own connection, not with the visitor’s table permissions, so it has to decide for itself which rows the caller may have; it cannot take record IDs or filter expressions from the request and pass them through. And the web role on the flow is the only thing stopping any signed-in user from calling it, so assign it deliberately.

Note where the work happens: filtering and paging on the server, rendering on the client. Do it the other way round and you’re shipping the whole table to a phone.

How to make a mess and fix it

The performance checklist, roughly in the order things bite:

  1. Large datasets - paginate and filter server-side, not in JavaScript
  2. Memory leaks - clean up DOM elements and event listeners you replace
  3. Chatty network - debounce the filters, cache the results
  4. Slow rendering - virtual scrolling once lists get long
  5. Export timeouts - stream big exports rather than building them in memory
  6. Complex filter combinations - go optimise the underlying query

Wrapping up

Filtering, sorting, export and bulk actions turn a table into something people work in. Build for the data volume you’ll have in two years, keep the heavy lifting on the server, and check it holds up on a phone and with a screen reader.

Next: web templates, and the reusable building blocks behind consistent site design.