FUIDataTableModel
public class FUIDataTableModel
FUIDataTableModel
is the data structure being used in FUIDataTable
view.
Code Usage:
let header = FUITableRowItem(leadingAccessories: [], trailingAccessory: nil, data: titles)
let model = FUIDataTableModel(headerData: nil,
rowData: rowData,
isHeaderSticky: true,
isFirstColumnSticky: true,
columnAttributes: columnAttributes,
rowAlignment: .top,
isPinchZoomEnable: false,
showRowDivider: true,
showColoumnDivider: true,
headerCellPadding: UIEdgeInsets(top: 8, left: 16, bottom: 8, right: 16),
dataCellPadding: UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16),
minRowHeight: 48,
minColumnWidth: 48,
allowsPartialRowDisplay: true,
backgroundColor: .white,
showListView: false)
model.didSelectRowAt = { _ in
print(model.selectedIndexes)
}
/// set a closure to check whether a dataItem located at (rowIndex, columnIndex) is valid; If it is valid, returns (true, nil); if it is not valid, returns false and an error message which is shown to users.
model.validateDataItem = { rowIndex, columnIndex, dataItem in
...
}
/// set a closure to provide a `FUIDataListItem` type dataItem located at (rowIndex, columnIndex) for an array of Strings and a title for inline editing mode
model.listItemDataAndTitle = { rowIndex, columnIndex in
...
}
/// set a closure to observe a value change for inline editing mode
model.valueDidChange = { change in
print("valueDidChange: \(change.description)")
}
-
Edit mode for FUIDataTable
See moreDeclaration
Swift
public enum EditMode : Int, CaseIterable
-
FUITableRowItem
, header data for displaying.Declaration
Swift
public var headerData: FUITableRowItem? { get set }
-
row data (header is not included)
Declaration
Swift
public var rowData: [FUITableRowItem] { get set }
-
Switching between normal and editing mode.
Declaration
Swift
@available(*, deprecated, renamed: "editMode") public var isEditing: Bool { get set }
-
edit mode
Declaration
Swift
public var editMode: EditMode { get set }
-
Set header to be sticky.
Declaration
Swift
public var isHeaderSticky: Bool { get set }
-
Set first column to be sticky.
Declaration
Swift
public var isFirstColumnSticky: Bool { get set }
-
Set horizontal scrolling.
Declaration
Swift
public var horizontalScrolling: Bool { get set }
-
Show list view in iPhone protrait mode.
Declaration
Swift
public var showListView: Bool { get set }
-
Enable or disable pinch and zoom.
Declaration
Swift
public var isPinchZoomEnable: Bool { get set }
-
show or hide row dividers
Declaration
Swift
public var showRowDivider: Bool { get set }
-
the row divider height
Declaration
Swift
public var rowDividerHeight: CGFloat { get set }
-
the row divider color
Declaration
Swift
public var rowDividerColor: UIColor { get set }
-
the column divider width
Declaration
Swift
public var columnDividerWidth: CGFloat { get set }
-
the column divider color
Declaration
Swift
public var columnDividerColor: UIColor { get set }
-
show or hide row dividers
Declaration
Swift
public var everyNumOfRowsToShowDivider: Int { get set }
-
show or hide first column divider
Declaration
Swift
public var showColoumnDivider: Bool { get set }
-
custom header cell’s padding; if set it overwrites default value
Declaration
Swift
public var headerCellPadding: UIEdgeInsets? { get set }
-
custom data cell’s padding; if set it overwrites default value
Declaration
Swift
public var dataCellPadding: UIEdgeInsets? { get set }
-
min row height
Declaration
Swift
public var minRowHeight: CGFloat { get set }
-
min column width
Declaration
Swift
public var minColumnWidth: CGFloat { get set }
-
whether allows to display partial row; For Table Card, set this to false
Declaration
Swift
public var allowsPartialRowDisplay: Bool { get set }
-
background color
Declaration
Swift
public var backgroundColor: UIColor { get set }
-
Column attribute for each column.
Declaration
Swift
public var columnAttributes: [FUITableColumnAttribute] { get set }
-
row alignment
Declaration
Swift
public var rowAlignment: FUIDataTableRowAlignment { get set }
-
Selection did change handler.
Declaration
Swift
public var didSelectRowAt: ((_ index: Int) -> Void)? { get set }
-
Selected Indexes.
Declaration
Swift
public var selectedIndexes: [Int] { get set }
-
a closure to check whether a dataItem located at (rowIndex, columnIndex) is valid; If it is valid, returns (true, nil); if it is not valid, returns false and an error message which is shown to users.
Declaration
Swift
public var validateDataItem: ((_ rowIndex: Int, _ columnIndex: Int, _ dataItem: FUITableItem) -> (Bool, String?))? { get set }
-
a closure to provide a ‘DataListItem’ type dataItem located at (rowIndex, columnIndex) for an array of Strings and a title to choose when it is in inline edit mode.
Declaration
Swift
public var listItemDataAndTitle: ((_ rowIndex: Int, _ columnIndex: Int) -> (listItems: [String], title: String))? { get set }
-
value did change
Declaration
Swift
public var valueDidChange: ((FUIDataTableChange) -> Void)? { get set }
-
a closure to provide contentOffset and the index of visible rows and columns when the user scrolls the content view within the FUIDataTable.
Declaration
Swift
public var didScroll: ((_ contentOffset: CGPoint, _ indexOfRows: [Int], _ indexOfColumns: [Int]) -> Void)? { get set }
-
init(headerData:rowData:isHeaderSticky:isFirstColumnSticky:columnAttributes:rowAlignment:isPinchZoomEnable:showRowDivider:rowDividerHeight:rowDividerColor:everyNumOfRowsToShowDivider:showColoumnDivider:columnDividerWidth:columnDividerColor:headerCellPadding:dataCellPadding:minRowHeight:minColumnWidth:allowsPartialRowDisplay:backgroundColor:showListView:editMode:)
Public initializer for FUIDataTableModel.
Declaration
Swift
public init(headerData: FUITableRowItem? = nil, rowData: [FUITableRowItem] = [], isHeaderSticky: Bool = false, isFirstColumnSticky: Bool = false, columnAttributes: [FUITableColumnAttribute] = [], rowAlignment: FUIDataTableRowAlignment = .top, isPinchZoomEnable: Bool = false, showRowDivider: Bool = true, rowDividerHeight: CGFloat = 1, rowDividerColor: UIColor = UIColor.preferredFioriColor(forStyle: .separator), everyNumOfRowsToShowDivider: Int = 1, showColoumnDivider: Bool = true, columnDividerWidth: CGFloat = 1, columnDividerColor: UIColor = UIColor.preferredFioriColor(forStyle: .separator), headerCellPadding: UIEdgeInsets? = nil, dataCellPadding: UIEdgeInsets? = nil, minRowHeight: CGFloat = 48, minColumnWidth: CGFloat = 48, allowsPartialRowDisplay: Bool = true, backgroundColor: UIColor = UIColor.preferredFioriColor(forStyle: .secondaryGroupedBackground), showListView: Bool = false, editMode: EditMode = .none)
Parameters
headerData
Header data for displaying.
rowData
Data for each row.
isHeaderSticky
Set header to be sticky.
isFirstColumnSticky
Set first column to be sticky.
columnAttributes
Column attribute for each column.
rowAlignment
Row alighnemt
isPinchZoomEnable
Set if pinch and zoom enble, the default is false.
showRowDivider
Show or hide row dividers
rowDividerHeight
The row divider height
rowDividerColor
The row divider color
everyNumOfRowsToShowDivider
Show row dividers in every number of Rows; The values must be >= 1; The default is 1.
showColoumnDivider
Show or hide first column divider
columnDividerWidth
The column divider width
columnDividerColor
The column divider color
headerCellPadding
Custom header cell’s padding
dataCellPadding
Custom data cell’s padding
minRowHeight
Min row height
minColumnWidth
Min column width
allowsPartialRowDisplay
Whether allows to display partial row; For Table Card, set this to false
backgroundColor
background color
showListView
Show list view in iPhone protrait mode
editMode
one of edit mode; The default is ‘.none’.
-
Append rows to the end of FUIDataTable
Declaration
Swift
public func appendRows(_ data: [FUITableRowItem])
Parameters
data
an array of FUITableRowItem