> For the complete documentation index, see [llms.txt](https://docs.avonnicomponents.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avonnicomponents.com/experience-cloud/tutorials/reactive-components/linked-data-tables.md).

# Linked Data Tables

## Keeping Tables in Sync

Imagine you have two tables on your page:

1. **Accounts Table:** This table (`accountsDatatable`) lists all your customer accounts.
2. **Contacts Table:** This table (`contactsDatatable`) lists all the contact people for your accounts.

**The Goal:** When you select an account in the Accounts Table, you want the Contacts Table to automatically update and show only the contacts for *that specific* account.

## **How to Make It Happen**

### **The Accounts Table**

* Drag the Avonni Data Table Component
* Make sure you've given this table the API name `accountsDatatable`.
* Configure the Data Source by using the Query Data Source
* Select the Accounts object
* Configure the Data Mappings to create columns

<figure><img src="https://2929066058-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDL6JQuZArjJeQvX2ot4y%2Fuploads%2Fgit-blob-6c5c0db82baf8877ee1102d13e33bb64c965c1aa%2F2024-05-28_20-33-37.png?alt=media" alt=""><figcaption></figcaption></figure>

### **The Contacts Table**

* This table is also set up, showing all your contacts.
* Go to the "Data Source" section in the table's settings.
* Choose the "Query Data Source" option.
* Select the object that holds your contact information (e.g., "Contact").
* Add a filter condition:
  * Field: `Account Id` (or whichever field links contacts to accounts)
  * Operator: `Equals`
  * Value: `{{accountsDatatable.selectedRecord.Id}}`
    * This expression code tells the Contacts Table to show only contacts whose Account ID matches the ID of the selected row in the Accounts Table.
* Create columns by adding fields.

### **The Result**

* Users browse their account list in the Accounts Table.
* They click on an account.
* The Contacts Table instantly updates to show only the contacts associated with that chosen account.

This keeps your tables in sync and provides a smooth, intuitive user experience.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avonnicomponents.com/experience-cloud/tutorials/reactive-components/linked-data-tables.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
