Table Columns
Tables in Elaris.UI are built using TableColumn, TableRow, and TableCell classes. Understanding these is essential for working with tables.
TableColumn
Section titled “TableColumn”TableColumn defines a column in the table, including its name, width, and how to extract data from row objects.
Properties
Section titled “Properties”Name: Column name (displayed in header)Width: Column width in charactersMinWidth: Minimum column widthAlignment: Text alignment (Left, Center, Right)IsVisible: Whether the column is visiblePropertyName: Property name to bind to
Binding Data
Section titled “Binding Data”Bind to Property Name
Section titled “Bind to Property Name”table.AddColumn("Name", 20).BindTo("FullName");Bind with Lambda
Section titled “Bind with Lambda”table.AddColumn("Age", 10).BindTo<Person>(p => p.Age);Custom Value Getter
Section titled “Custom Value Getter”var column = new TableColumn("Display", 20);column.ValueGetter = obj => obj is Person p ? $"{p.FirstName} {p.LastName}" : null;table.AddColumn(column);TableRow
Section titled “TableRow”TableRow represents a single row in the table.
Properties
Section titled “Properties”Data: The data object associated with the rowIndex: The row indexCells: Dictionary of cells by column
Accessing Cells
Section titled “Accessing Cells”var cell = row.GetCell(column);cell.Value = "New Value";TableCell
Section titled “TableCell”TableCell represents a single cell in the table.
Properties
Section titled “Properties”Value: The cell valueColumn: The associated columnRow: The associated row
Rendering
Section titled “Rendering”Cells are automatically rendered by the table. You can customize rendering by creating custom cell types (see Specialized Columns).
Usage Example
Section titled “Usage Example”// Create columnsvar nameColumn = new TableColumn("Name", 30);var ageColumn = new TableColumn("Age", 10).BindTo<Person>(p => p.Age);
table.AddColumn(nameColumn);table.AddColumn(ageColumn);
// Add rowsvar row1 = table.AddRow(new Person("Alice", 30));var row2 = table.AddRow(new Person("Bob", 25));
// Access cell valuesvar cell = row1.GetCell(nameColumn);cell.Value = "Alice Smith";Related Widgets
Section titled “Related Widgets”- Table - Main table widget
- Specialized Columns - CheckboxColumn, ProgressColumn