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
| Property | Default | Purpose |
|---|---|---|
| defaultOrdering | nil | Initial sort column |
| isColumnSortable | nil (all sortable) | Per-column sort control |
| shouldShowHeaderSortingIndicator | true | Header sort arrows |
| shouldShowFooterSortingIndicator | false | Footer sort arrows |
| shouldFooterTriggerSorting | false | Footer taps trigger sort |
| sortArrowTintColor | .tintColor | Arrow color |
| heightForSectionHeader | 44 | Header height |
| heightForSectionFooter | 44 | Footer height |
| heightForSearchView | 60 | Search bar height |
| heightOfInterRowSpacing | 1 | Row gap |
| rowHeightMode | .fixed(44) | Row height strategy |
| shouldShowFooter | true | Footer visibility |
| shouldShowSearchSection | true | Search visibility |
| shouldShowVerticalScrollBars | true | Vertical scroll indicator |
| shouldShowHorizontalScrollBars | true | Horizontal scroll indicator |
| shouldSectionHeadersFloat | true | Sticky header |
| shouldSectionFootersFloat | true | Sticky footer |
| shouldSearchHeaderFloat | false | Sticky search |
| columnWidthMode | .fitContentText(...) | Width calculation |
| minColumnWidth | 70 | Minimum width |
| maxColumnWidth | nil | Maximum width |
| shouldContentWidthScaleToFillFrame | true | Fill frame |
| lockColumnWidthsAfterFirstLayout | false | Lock widths after layout |
| fixedColumns | nil | Frozen columns |
| textLayout | .singleLine() | Text display |
| cellSizingMode | .defaultCell | Sizing strategy |
| highlightedAlternatingRowColors | [...] | Sorted column row colors |
| unhighlightedAlternatingRowColors | [...] | Non-sorted column row colors |
| defaultCellConfiguration | nil | Per-cell styling callback |
| shouldSupportRightToLeftInterfaceDirection | false | RTL 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 = .systemBlueColumn 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 = trueRow 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