Is it possible to filter or hide rows in DITA tables?

In DITA, native support for filtering or hiding rows within tables is limited. DITA tables are primarily designed for structured data presentation and do not include built-in features for dynamic filtering or hiding of rows. Achieving row filtering or hiding typically requires post-processing, custom scripting, or the use of external tools to manipulate the table content based on specific criteria.

DITA tables are static structures, and any dynamic manipulation of table content, such as filtering or hiding rows, often involves processes beyond what DITA provides natively. However, it can still be accomplished by manual filtering.

Methods of Row Filtering

Manual Filtering

Authors can manually exclude rows they wish to hide from the table within the DITA source. This can be done through direct manipulation of the table, which goes against DITA best practices, or by conditional processing, which involves extensive use of metadata on a row-by-row basis. This approach is not dynamic and requires manual editing of the content to achieve the desired result.

Post-Processing

After creating DITA content, post-processing scripts or tools can be used to parse the DITA source and generate output with filtered or hidden rows based on specific criteria.

Custom Scripting

For more dynamic behavior, custom scripts can be applied to DITA content during or after processing to implement row filtering or hiding based on certain conditions or user interactions. This method may involve JavaScript when generating HTML output from DITA.

External Tools

Using external applications or tools designed for structured data manipulation, such as custom software or spreadsheet software, allows filtering or hiding rows based on criteria external to DITA.

Example


    <table>
      <caption>Sample Data Table</caption>
      <thead>
        <tr>
          <th scope="col">First Name</th>
          <th scope="col">Last Name</th>
          <th scope="col">Age</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>John</td>
          <td>Doe</td>
          <td>35</td>
        </tr>
        <!-- The following row is hidden manually -->
        <!-- <tr>
          <td>Alice</td>
          <td>Smith</td>
          <td>28</td>
        </tr> -->
        <tr>
          <td>Bob</td>
          <td>Johnson</td>
          <td>42</td>
        </tr>
      </tbody>
    </table>
  

In this example, the row containing data for Alice Smith is hidden manually by enclosing it in comments. This approach is static and not user-driven, as it requires direct modification of the DITA source. This method is strongly discouraged.