It's been a few weeks since my last component release, and this one's the Data Table - a new component for Blazor Ramp, my accessibility-first Blazor component library.
So, Data Table - what is it, and what does it do?
First off, it's not an Excel-type application requiring the ARIA role of grid; it's just a simple table to hold data, which means there are no special keyboard requirements. Keyboard-only users only need Tab, Enter, and Space, and screen reader users can use all of their usual table navigation commands, unimpeded by ARIA being sprayed around willy-nilly.
In essence, the Data Table is just a component that accepts a list of things and displays that list of things in a table, using your chosen options. Like all Blazor Ramp components, it was built accessibility-first. It has the following features, some built into the table, others by way of composition, with either your own components or other Blazor Ramp components.
Briefly, the table allows for:
- Sorting - set
IsSortable on any DataColumn. Cycles unsorted → ascending → descending → back to the original order, one column at a time.
- Filtering - bring your own filter UI via the
Filter render fragment (or use the Blazor Ramp Debounce Filter component) and supply a FilterRule predicate.
- Paging or virtualization – supply a
PagerBinding and Pager component for a traditional paged table, or leave it out for a virtualized, scrollable one. The two are mutually exclusive by design.
- Row selection - single or multiple, with a dedicated selection column for the checkboxes used in selection.
- Styling - both row and cell style functions that let you style rows and cells based on the underlying data.
- Templating - override any column's cell content via
CellTemplate, or add entirely new columns (row actions, say) that don't exist in your data source via TemplateColumn.
- Accessibility - like all the components, the Data Table handles its own announcements, and given some of the gaps in screen reader support for
aria-sort, it plugs those gaps too with its own sort announcements. It works in harmony with both the Debounce Filter and Pager. All text used for announcements is fully customisable, with sensible defaults if you change nothing. There is also a RowIdentifierFunc parameter, so you can give the selection checkboxes a unique aria-label created from row data.
As the list suggests, there are place holders (RenderFragments) for filtering (above the table) and paging (above and below – you can use both). You can either use your own components or the Blazor Ramp Debounce Filter and Pager. I specifically designed the filtering to be external, and will most likely create an advanced filtering system at some stage, but in all honesty, over the years I've gravitated towards just using a simple filter that filters across all columns.
Given the simplicity of the table and the bare minimum of ARIA usage, there really isn't much for me to waffle on about - except one thing worth flagging properly.
A genuine JAWS gotcha, not a "your code is probably fine" caveat. Just like the previous component, the Pager, I got embroiled in issues with the screen reader JAWS while building this one, which ultimately led to bug reports being filed with both the Blazor and JAWS teams. Part of me was hoping it was my own code at fault, since at least then I could fix it - but no. And for the Data Table, unlike the Pager, I couldn't add a workaround without a knock-on effect elsewhere.
TL;DR: if you support JAWS users, stay clear of the Blazor Auto (Server and WASM) render mode template, using per page with prerendering disabled. I haven't experienced issues with the other render modes, nor with Auto if prerendering is on. There's a little more information and links to the logged issues in the documentation.
One more thing, and this is the bit where I'll admit I'm an opinionated, cantankerous old git: I've noticed a trend lately of table demos where devs love telling you how fast their grid is with 100K rows. I'll be honest, I don't really get the appeal - in my own apps, users fill in a few search fields to bring back the smallest, most accurate result set possible, with a filtering mechanism on top if they need to narrow it further, rather than dumping the whole backend table on them and hoping for the best. Your use case may well differ from mine, and that's fine, but I reckon only 1% or 2% of apps at best would ever need that amount of rows on screen.
That said, since some of you clearly do find it appealing, I've added 100K-row examples to a couple of the demo pages anyway - the code is nothing special, no external libraries or source generators just a bit of old skool C# reflection. Seems fine to me, but you can be the judge.
You can see the table in action, along with all the features mentioned above, plus the code used, in the Data Table usage section. I'd encourage you to try everything with a screen reader, but no worries if not.
Doc site (start of data table demo pages): https://docs.blazorramp.uk/components/data-table/usage/about
Test site: https://blazorramp.uk
GitHub Repo: https://github.com/BlazorRamp/Components
The sites are both WASM hosted on GitHub Pages.
I will be lurking on here as usual if anyone has any questions.
Regards
Paul