Configuration Reference

Complete reference of all configuration options in DataTableConfiguration.

Creating a Configuration

var config = DataTableConfiguration()
// Modify properties...
let dataTable = SwiftDataTable(data: items, columns: columns, options: config)

Quick Reference Table

PropertyDefaultPurpose
defaultOrderingnilInitial sort column
isColumnSortablenil (all sortable)Per-column sort control
shouldShowHeaderSortingIndicatortrueHeader sort arrows
shouldShowFooterSortingIndicatorfalseFooter sort arrows
shouldFooterTriggerSortingfalseFooter taps trigger sort
sortArrowTintColor.tintColorArrow color
heightForSectionHeader44Header height
heightForSectionFooter44Footer height
heightForSearchView60Search bar height
heightOfInterRowSpacing1Row gap
rowHeightMode.fixed(44)Row height strategy
shouldShowFootertrueFooter visibility
shouldShowSearchSectiontrueSearch visibility
shouldShowVerticalScrollBarstrueVertical scroll indicator
shouldShowHorizontalScrollBarstrueHorizontal scroll indicator
shouldSectionHeadersFloattrueSticky header
shouldSectionFootersFloattrueSticky footer
shouldSearchHeaderFloatfalseSticky search
columnWidthMode.fitContentText(...)Width calculation
minColumnWidth70Minimum width
maxColumnWidthnilMaximum width
shouldContentWidthScaleToFillFrametrueFill frame
lockColumnWidthsAfterFirstLayoutfalseLock widths after layout
fixedColumnsnilFrozen columns
textLayout.singleLine()Text display
cellSizingMode.defaultCellSizing strategy
highlightedAlternatingRowColors[...]Sorted column row colors
unhighlightedAlternatingRowColors[...]Non-sorted column row colors
defaultCellConfigurationnilPer-cell styling callback
shouldSupportRightToLeftInterfaceDirectionfalseRTL layout support

Sorting Options

// Initial sort
config.defaultOrdering = DataTableColumnOrder(index: 2, order: .descending)

// Disable sorting on specific columns
config.isColumnSortable = { columnIndex in
    columnIndex != 5  // Column 5 is not sortable
}

// Sort indicator visibility
config.shouldShowHeaderSortingIndicator = true
config.shouldShowFooterSortingIndicator = false
config.shouldFooterTriggerSorting = false
config.sortArrowTintColor = .systemBlue

Column Width Options

// Global width mode
config.columnWidthMode = .fitContentText(
    strategy: .hybrid(sampleSize: 100, averageCharWidth: 7.0)
)

// Constraints
config.minColumnWidth = 70
config.maxColumnWidth = 300

// Per-column overrides
config.columnWidthModeProvider = { columnIndex in
    switch columnIndex {
    case 0: return .fixed(width: 60)
    default: return nil
    }
}

// Lock after first layout
config.lockColumnWidthsAfterFirstLayout = true

// Scale to fill
config.shouldContentWidthScaleToFillFrame = true

Row Height Options

// Fixed height (fastest)
config.rowHeightMode = .fixed(44)

// Automatic height based on content
config.rowHeightMode = .automatic(estimated: 44, prefetchWindow: 10)

Text Layout Options

// Single line with truncation (default)
config.textLayout = .singleLine(truncation: .byTruncatingTail)

// Multi-line wrapping
config.textLayout = .wrap