TableRow.isHeader: true should make row added to thead section of table

The constructors for the LINQPad.Controls.TableRow has an isHeader parameter which controls what type of cells are auto generated when given a collection of controls. But otherwise, it's treated as a normal row.

It ought to also control what section of the Table it is rendered in as well and put these rows in the thead section. Right now, all rows are thrown into the tbody of the Table class.

I have my own custom implementations to work around this, but it ought to be in the builtins.

class TableRowEx : TableRow
{
    ...
    public bool IsHeader { get; set; }
}
class TableEx : Table
{
    ...
    protected override void OnRendering(EventArgs e)
    {
        var partition = Rows.ToLookup(r => r.IsHeader);
        VisualTree.Clear();
        if (partition[true].Any())
            VisualTree.Add(new Control("thead", partition[true]));
        VisualTree.Add(new Control("tbody", partition[false]));
        base.OnRendering(e);
    }
}

Comments

  • Makes sense. HeaderStyles and CellStyles would need to be updated, too. But could this a breaking change?

  • JeffMercado
    edited January 9

    It could be, but I think for the better. One would think that argument would apply to the row, and not the autogenerated cells for controls it contains. I think that would make sense for a "default config" for the cells for that row, rather than a ctor argument.

    This only came up for me because I was trying to mimic the way objects were dumped and the way the styles are set, it requires the header row to be in <thead>. Sure I could change the styles but I wanted to make it all work in vanilla.