# Set your Data Table to Auto-Refresh

> Please note that this is now available as a plugin for easier installation. While you can use this document as a reference, the recommended method to add…

Source: https://tadabase.com/docs/snippets/set-your-data-table-to-auto-refresh  
Status: Not yet re-checked. Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

> **Warning:** Please note that this is now available as a plugin for easier installation. While you can use this document as a reference, the recommended method to add this functionality is through the plugin installation wizard. Learn more about plugins [here](https://tadabase.com/docs).

![Screenshot for “Set your Data Table to Auto-Refresh”](https://community.tadabase.io/uploads/default/original/2X/2/208a7b17b4a29298605e5d85c2da0925ade3d370.gif)

There are many use cases for wanting your tables to refresh automatically to see the information. Here are the steps you can take to set this up.

**Step 1 Add the CSS Class action-link-refresh to the action link column(s), as shown in the image below.**

> **Note:** **Please Note:** You will need to add this to **both action links** if you want it to work both ways, as shown in the example above.

![Screenshot for “Set your Data Table to Auto-Refresh”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-08/scaled-1680-/2022-08-25_14-04-27.png)

**Step 2 Find the Component IDs for both tables as shown in the image below. You will need these for the next and last step!**

![Screenshot for “Set your Data Table to Auto-Refresh”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-08/scaled-1680-/2022-08-25_14-10-34.png)

**Step 3 Finally, copy and paste the following code into the JavaScript section of your page.**

```
var timeToWaitBeforeRefreshTriggers = 600; // Set this to the amount of time it takes for the action link to complete (milliseconds)
var tableOneId = 'component_X1'; // Change this to the first table ID
var tableTwoId = 'component_X2'; // Change this to the second table ID

var setOnClick = function() {
    $('.x-type-data-table').find('.action-link-refresh a').click(function() {
        setTimeout(function() {
            $('[ng-click="refreshData()"]').click();
        }, timeToWaitBeforeRefreshTriggers);
    });
};
TB.render(tableOneId, function() {
    setOnClick();
});
TB.render(tableTwoId, function() {
    setOnClick();
});
$('body').click(function() { // Reset after any action that can wipe the onclick event occurs by using body onclick
    setTimeout(function() {
        $('tbody tr').find('.action-link-refresh a').off();
        setOnClick();
    }, 800);
});
```

> **Note:** Remember to change **component_X1** and **component_X2** in the code to the component IDs from step 2.

![Screenshot for “Set your Data Table to Auto-Refresh”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-08/scaled-1680-/2022-08-25_14-14-49.png)

**Original Community Post:**

[https://community.tadabase.io/t/auto-refresh-for-datatable/309/4](https://community.tadabase.io/t/auto-refresh-for-datatable/309/4)
