Respec: Make table rows sortable

Created on 26 Apr 2021  路  6Comments  路  Source: w3c/respec

Is your feature request related to a problem? Please describe.
When there is a big table...

Describe the solution you'd like
It would be nice for big tables to sort by column.

Feature request

Most helpful comment

Some thoughts on requirements:

  • Sort should be on the text content of the <td> elements and not on (HTML) elements. Sounds obvious, but I saw simple tools that, when sorting, did sorted <a href="...">XYZ</a> before <b>ABC</b>...
  • Probably also obvious, but sorting means only on rows with within a <tbody> section, not on <thead> section. If there are several <thead> elements then... I would think that the corresponding <tbody> elements are sorted independently of the others, ie, every <thead> - <tbody> pair is a separate "sorting context". But opinions may differ on this.
  • I am not sure what to do with a simple table without the <thead>-<tbody> pairs. I would not be shocked if those tables could not be sorted :-)
  • The user should have a possibility to choose between ascending and descending order (usually through either a choice in the header using some icons, or by repeatedly clicking on the header).
  • Whether a table is sortable or not could be controlled, e.g., by special classes.
  • Bonus feature: possibility to automatically cut a large table to smaller chunks (say, 10 entries) and move from one chunk to the other via some extra user interface. (This is a bonus feature, ie, it may not be a requirement in the first round.)

All 6 comments

Like on a button/header click or as a pre-process step?

@sidvishnoi, see https://github.com/w3c/did-spec-registries/pull/273 ... but will try to get clear requirements from there.

I think we might want dynamic (click-based), not preprocessed... so including another .runtime.

Some thoughts on requirements:

  • Sort should be on the text content of the <td> elements and not on (HTML) elements. Sounds obvious, but I saw simple tools that, when sorting, did sorted <a href="...">XYZ</a> before <b>ABC</b>...
  • Probably also obvious, but sorting means only on rows with within a <tbody> section, not on <thead> section. If there are several <thead> elements then... I would think that the corresponding <tbody> elements are sorted independently of the others, ie, every <thead> - <tbody> pair is a separate "sorting context". But opinions may differ on this.
  • I am not sure what to do with a simple table without the <thead>-<tbody> pairs. I would not be shocked if those tables could not be sorted :-)
  • The user should have a possibility to choose between ascending and descending order (usually through either a choice in the header using some icons, or by repeatedly clicking on the header).
  • Whether a table is sortable or not could be controlled, e.g., by special classes.
  • Bonus feature: possibility to automatically cut a large table to smaller chunks (say, 10 entries) and move from one chunk to the other via some extra user interface. (This is a bonus feature, ie, it may not be a requirement in the first round.)

@iherman covered all the requirements I was about to write, and a few I hadn't thought of just now (though similar have bitten me in the past). Having these features available will be of great benefit to many spec contributors/authors/editors/etc.

While you're in there: I've had requests for floating column heads, so that for large tables with many columns, you can always see the column title.

Ah, yeah. We should make those "sticky" - good suggestion @gkellogg. We can probably prototype that here and then push the CSS to the /tr-design repo.

Was this page helpful?
0 / 5 - 0 ratings