Displaying Related Collection and Subcollection Data in a DataTable

Database & APIs

I currently have a structure where I can select a user and retrieve their information in a DataTable widget. However, I would like to extend this functionality by associating it with a subcollection that stores the user's attendance records. Specifically, I need to display today's attendance for each user within the same DataTable.

Currently, my structure is as shown in the attached image. I would like to understand how to properly fetch and display data from both the main collection (users) and its subcollections (attendances) for each document.

Key Requirements:

  • The DataTable widget must be used because it provides essential features like pagination, user selection, sorting, and filtering.

  • I do not want to use ListView, custom-built columns, or manually structured layouts—it must be implemented directly in a DataTable.

  • The solution should efficiently retrieve and associate the user's attendance record (specifically, today’s attendance) alongside their existing user data.

What have you tried so far?
  1. Manual Table with Dynamic Queries

    • I created a table manually, adding columns and using dynamic generate query for each.

    • On the main page, I added an action to load the queries from the necessary collections.

    • However, I don’t want to use this approach since I need the integrated DataTable widget, which includes pagination, record selection, and built-in features.

  2. Fetching Data from Collection and Subcollection

    • I successfully retrieved queries for both the main collection and its subcollection and displayed them in a column. (But not in a Datatable widget)

    • However, I can’t establish relationships between the data (e.g., linking attendance status to the correct user or date).

I would like to know how to properly relate subcollection data with its parent collection inside a DataTable widget.

Did you check FlutterFlow's Documentation for this topic?
Yes
1