-
-
Notifications
You must be signed in to change notification settings - Fork 70
🥶 How to freeze columns
Pavan Kataria edited this page Jul 9, 2019
·
2 revisions
Here's how you define which columns you want frozen, by using the all new DataTableFixedColumnType
class, and using any of the initialisers like so
// Example 1 - freeze from the left
DataTableFixedColumnType(leftColumns: 1) // this will freeze the n number of columns from the left of the table. In this case column number 1 - the first columns. This is a one-index based system
// Example 2 .- freeze from the right
DataTableFixedColumnType(rightColumns: 1) // this will freeze n number of columns from the right of the table. In this case the last column.
// Example 3 - multiple columns
DataTableFixedColumnType(leftColumns: 2, rightColumns1) // You can specify multiple columns to be frozen on both sides. In this case the first 2 columns and the last column.
You can implement fixed columns in your data table in two ways:
Simply adopt the SwiftDataTable's delegate method with the following signature:
@objc optional func fixedColumns(for dataTable: SwiftDataTable) -> DataTableFixedColumnType {
// and return the object here
return .init(leftColumn: 2) // freeze the first two columns
}
var configuration = DataTableConfiguration()
configuration.fixedColumns = .init(leftColumns: 2, rightColumns: 1) // freeze both the first two columns, and the last column