Advanced Table Features

Custom Cell Rendering

Apply custom formatting to specific columns:

table.Column("Status", col => {
    col.Render(value => {
        var color = value == "Active" ? TablerColor.Green : TablerColor.Red;
        return new TablerBadge(value, color);
    });
});

Nested Objects

HtmlForgeX automatically flattens nested objects for table display:

var data = employees.Select(e => new {
    e.Name,
    e.Department.Name,      // Flattened from nested object
    e.Address.City           // Flattened from nested object
});

Relative Time Formatting

DateTime columns can display relative time (e.g., "2 hours ago"):

table.Column("LastLogin", col => {
    col.WithRelativeTimeFormatter();
});

Duration Formatting

TimeSpan columns are automatically formatted as human-readable durations:

// Output: "2h 15m" instead of "02:15:00"

AOT Compatibility

For .NET 8 AOT scenarios, use the AOT-safe labeler pattern:

table.WithAotSafeLabeler<Employee>(labeler => {
    labeler.Label(e => e.FirstName, "First Name");
    labeler.Label(e => e.LastName, "Last Name");
});

Lazy Initialization

For large datasets, use lazy initialization to defer rendering:

table.EnableLazyInit();