# Auto-Refreshing Tables

**URL:** <https://forums.knack.com/t/auto-refreshing-tables/9675>\
**Category:** Feature Requests\
**Tags:** uiux-live-app, usability\
**Created:** [May 29, 2015, 6:29pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675 "2015-05-29T18:29:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnKatez44398](https://avatars.discourse-cdn.com/v4/letter/j/977dab/32.png) [@JohnKatez44398](https://forums.knack.com/u/JohnKatez44398)\
**Post date:** [May 29, 2015, 6:29pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/1 "2015-05-29T18:29:00Z")

</div>

It would be awesome to have the ability to auto-refresh a table on a page. We have a table that a lot of our employees use to update customer records, and everybody has to constantly F5 to make sure they have the latest and greatest before updating old information.

---

<div class="post-metadata">

**Author:** ![Guilhermeb42087](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@Guilhermeb42087](https://forums.knack.com/u/Guilhermeb42087)\
**Post date:** [April 8, 2018, 5:15am UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/2 "2018-04-08T05:15:55Z")

</div>

Hey Andrew, what is the code for #view\_1111?

Tks!

---

<div class="post-metadata">

**Author:** ![Guilhermeb42087](https://avatars.discourse-cdn.com/v4/letter/g/a87d85/32.png) [@Guilhermeb42087](https://forums.knack.com/u/Guilhermeb42087)\
**Post date:** [April 5, 2018, 12:13pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/3 "2018-04-05T12:13:46Z")

</div>

Voted!

---

<div class="post-metadata">

**Author:** ![AndrewGrya27012](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@AndrewGrya27012](https://forums.knack.com/u/AndrewGrya27012)\
**Post date:** [October 21, 2016, 8:43am UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/4 "2016-10-21T08:43:46Z")

</div>

Doing JS&nbsp;location.hash = location.hash + "#" is much faster than F5

---

<div class="post-metadata">

**Author:** ![PaulMcKinn11646](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@PaulMcKinn11646](https://forums.knack.com/u/PaulMcKinn11646)\
**Post date:** [August 11, 2016, 7:23am UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/5 "2016-08-11T07:23:01Z")

</div>

An auto-refreshing page would be great! &nbsp;... particularly if there was a setting to control exactly how often it should refresh.

---

<div class="post-metadata">

**Author:** ![MarkPauley76850](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@MarkPauley76850](https://forums.knack.com/u/MarkPauley76850)\
**Post date:** [December 29, 2015, 3:24pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/6 "2015-12-29T15:24:35Z")

</div>

AGREEEDDDD!!!!!

---

<div class="post-metadata">

**Author:** ![NormandDefayette\_CortexRD](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/normanddefayette_cortexrd/32/855_2.png) [@NormandDefayette\_CortexRD](https://forums.knack.com/u/NormandDefayette_CortexRD)\
**Post date:** [December 21, 2022, 11:21pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/7 "2022-12-21T23:21:09Z")

</div>

Hi to all,

Good news!! I’ve got exactly what you want. I’ve coded a library called **KTL** that does this without a single line of code. All you have to do is add **AUTOREFRESH=60** to the table’s title to get an update every minute.

If you’re interested, it’s open-source (free). All you have to do is copy/paste the **.js** and **.css** files to your app in the Builder.

Get **KTL** here: [https://github.com/cortexrd/Knack-Toolkit-Library](https://github.com/cortexrd/Knack-Toolkit-Library)

Enjoy!  
Normand D.  
Cortex R&D Inc.

---

<div class="post-metadata">

**Author:** ![Jon1](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@Jon1](https://forums.knack.com/u/Jon1)\
**Post date:** [February 25, 2023, 3:13pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/8 "2023-02-25T15:13:53Z")

</div>

Normand, any way of you posting the code here and is there away to implement your code without having to add “AUTOREFRESH=60” in the table’s title?

Thank you in advance… JON

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [February 25, 2023, 4:42pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/9 "2023-02-25T16:42:10Z")

</div>

Hi,

Try below code.

$(document).on(‘knack-view-render.view\_157’, function (event, view, records) {  
AutoRefresh(‘view\_157’,5000);  
});

function AutoRefresh(viewId,ms)  
{

setTimeout(function(){  
AutoRefresh(viewId,ms);  
Knack.views[viewId].model.data.fetch()  
},ms);

}

Change view id and ms according to your requirements.  
[https://roberts.knack.com/farmers#test-field/](https://roberts.knack.com/farmers#test-field/)

Regards,  
Sunny Singla  
[ssingla1985@gmail.com](mailto:ssingla1985@gmail.com)  
+919855089359

---

<div class="post-metadata">

**Author:** ![Jon1](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@Jon1](https://forums.knack.com/u/Jon1)\
**Post date:** [February 25, 2023, 10:20pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/10 "2023-02-25T22:20:19Z")

</div>

Hey Sunny, couldn’t get your code to work for me. I’m sure it something I did or didn’t do.

I changed view\_157 on first 2 lines to my view (view\_187) other than that, made no other changes.

Thanks as always… JON

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [February 26, 2023, 1:47am UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/11 "2023-02-26T01:47:26Z")

</div>

Hello John,

Yes, you just need to make only those changes. Share your page url where you implemented it.

It works for me can you check it on my given url

Regards,  
Sunny Singla

---

<div class="post-metadata">

**Author:** ![Jon1](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@Jon1](https://forums.knack.com/u/Jon1)\
**Post date:** [February 26, 2023, 2:34am UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/12 "2023-02-26T02:34:33Z")

</div>

I’ll put the code in an example app and email you. I did open your url link above but wasn’t sure if your sample program was doing what was expecting. I was hoping for a solution to refresh a given table’s data every few seconds or minutes. It was hard to tell what your app was doing. I inputted some same data but that’s about it.

---

<div class="post-metadata">

**Author:** ![BradStevens](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/bradstevens/32/140_2.png) [@BradStevens](https://forums.knack.com/u/BradStevens)\
**Post date:** [February 26, 2023, 6:44am UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/13 "2023-02-26T06:44:43Z")

</div>

@Sunny_Singla your code works for me.  
A tweak so it’s easier to paste into JS inside a view render:

```auto
$(document).on(‘knack-view-render.view_157’, function (event, view, records) {
     AutoRefresh(view.key,5000);
});

function AutoRefresh(viewId, ms) {
     setTimeout(function() {
          AutoRefresh(viewId, ms);
          Knack.views[viewId].model.data.fetch()
     }, ms);
}

```

Thanks @Sunny_Singla

---

<div class="post-metadata">

**Author:** ![Jon1](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@Jon1](https://forums.knack.com/u/Jon1)\
**Post date:** [February 26, 2023, 3:17pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/14 "2023-02-26T15:17:21Z")

</div>

Sunny, is there a solution that would stop the page from refreshing using your code when a user filters by search criteria.

Using your example app, when a user searches for “BMW” the table shows data containing “BMW” but then quickly refreshes and shows all table data. Any and all searches made are shown, but quickly refreshed within 5 seconds.

Also, is there a way for you to turn on “in line editing” for “testmessagename” field for your example app? I’d like to see if a user makes and submits changes this way if it will update on a 2nd open window within given time (ie 5 seconds). I couldn’t get changes made this way to reflect on 2nd open window in our app unless I pressed refresh on browser or F5.

Also, I created an “edit” link in our app that opened another page to edit given data. I couldn’t get updated/submitted data on 2nd open window unless we manually updated browser or pressed F5.

As always thank you… JON

---

<div class="post-metadata">

**Author:** ![NormandDefayette\_CortexRD](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/normanddefayette_cortexrd/32/855_2.png) [@NormandDefayette\_CortexRD](https://forums.knack.com/u/NormandDefayette_CortexRD)\
**Post date:** [March 11, 2023, 1:02pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/15 "2023-03-11T13:02:40Z")

</div>

Hi gentlemen,

I invite you to go see my new Youtube channel.

[Cortex R&D Inc - Youtube Knack tutorials and more](https://www.youtube.com/@cortexrdinc.4479)

I’ve just completed my first demo of the KTL. I think my auto refresh code adresses part of your problem since it pauses refreshing as soon and as long as you set the focus on a Search input field, and maintains the results afterwards.

Give it a try and let me know if it helps.  
Norm

---

<div class="post-metadata">

**Author:** ![RyanL](https://avatars.discourse-cdn.com/v4/letter/r/b487fb/32.png) [@RyanL](https://forums.knack.com/u/RyanL)\
**Post date:** [August 4, 2023, 3:07am UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/16 "2023-08-04T03:07:08Z")

</div>

Hi Sunny and Brad - I have tried both of your proposed solutions without success. Normand, your code looks interesting and addresses the issue indicated about search results refreshing, but I’m not prepared to implement everything at once nor do I want to spend time turning off functions of the code, perhaps one day!

Sunny and Brad, is there something Im missing in my code? I changed the view to my table view (857) but no luck. Any help is greatly appreciate!

$(document).on(‘knack-view-render.view\_857’, function (event, view, records) {  
AutoRefresh(‘view\_857’,5000);  
});

function AutoRefresh(viewId,ms)

{

setTimeout(function(){  
AutoRefresh(viewId,ms);  
Knack.views[viewId].model.data.fetch()  
},ms);

}

---

<div class="post-metadata">

**Author:** ![Sunny\_Singla](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/sunny_singla/32/1007_2.png) [@Sunny\_Singla](https://forums.knack.com/u/Sunny_Singla)\
**Post date:** [August 15, 2023, 5:48pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/17 "2023-08-15T17:48:38Z")

</div>

Hello Ryan,

Just see your message. And I don’t think there is any issue in this code.

May be some other issue. If possible share your page url so we can check.

Regards,  
Sunny Singla  
[ssingla1985@gmail.com](mailto:ssingla1985@gmail.com)  
+919855089359

---

<div class="post-metadata">

**Author:** ![NormandDefayette\_CortexRD](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/normanddefayette_cortexrd/32/855_2.png) [@NormandDefayette\_CortexRD](https://forums.knack.com/u/NormandDefayette_CortexRD)\
**Post date:** [August 28, 2023, 6:19pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/18 "2023-08-28T18:19:53Z")

</div>

> [@RyanL](#):
>
> Normand, your code looks interesting and addresses the issue indicated about search results refreshing, but I’m not prepared to implement everything at once nor do I want to spend time turning off functions of the code, perhaps one day!

Hi RyanL,

I’ve added a new template file for those like you who’d like to test the KTL with everything turned off, and enabling only the desired features one by one.

[See the updated documentation here](https://github.com/cortexrd/Knack-Toolkit-Library/wiki/Customizing-Features#disabling-a-feature).

Let me know if you have questions or concerns.

Norm

---

<div class="post-metadata">

**Author:** ![RobertHill\_UpHillSolutions](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/roberthill_uphillsolutions/32/3141_2.png) [@RobertHill\_UpHillSolutions](https://forums.knack.com/u/RobertHill_UpHillSolutions)\
**Post date:** [September 24, 2023, 3:29am UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/19 "2023-09-24T03:29:48Z")

</div>

Hey Normand,

Your KTL is pretty amazing. I haven’t used it personally but I am digging through your code and borrowing some features. I do have a couple of questions. I noticed in this thread that folks suggest using a five second interval along with Knack.views[view.key].model.data.fetch(). Meanwhile your code is 60 seconds and you use Knack.views[view.key].model.fetch().

I am curious if you noticed a difference between data and model refresh?

Also curious why you defaulted to 60 seconds? I tried the 5 second approach but I am worried if the amount of calls to the server could overload it. The server for one of my apps went down last night after introducing the 5 second interval and that was the only change I made.

---

<div class="post-metadata">

**Author:** ![NormandDefayette\_CortexRD](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/normanddefayette_cortexrd/32/855_2.png) [@NormandDefayette\_CortexRD](https://forums.knack.com/u/NormandDefayette_CortexRD)\
**Post date:** [September 25, 2023, 8:35pm UTC](https://forums.knack.com/t/auto-refreshing-tables/9675/20 "2023-09-25T20:35:45Z")

</div>

Hi Robert,

Thanks for the nice comments 🙂 Glad you like it.

About your questions:

1. fetch()

When I use Knack.views[‘view\_1’].model.data.fetch(); I see no updates in the view. As if it does nothing.

But when I use Knack.views[‘view\_1’].model.fetch(); I so see the updates.

**Note** that if you use the complete function **ktl.views.refreshView(‘view\_1’)**, it will work with ANY view types, not just grids. Even forms will refresh!

1. My default of 60 seconds was just an arbitrary choice, that I thought would make sense - not too slow nor too fast. I decided to enforce a lower limit of 5 seconds to avoid overloading the “already-busy-enough” servers 🙂

Of course, 5 seconds is quite fast for large tables with lots of rows and fields. But I can tell you that I use several grids with 10 seconds refresh where they have a single row and 5 fields - without problems.

It should not cause a Knack servers crash per say, but I noticed that the refresh function sometimes encounters errors 500, 502, etc. In such cases, the app needs to be reloaded manually (F5 or Ctrl+R) most of the time, unless it was caught by your code or the KTL and handled appropriately.

These unrecoverable errors are currently causing big problems to my client, where they have dozens of unattended dashboards across their industrial plant to monitor the production status.

I have developed a custom solution involving a NodeJS watchdog (they use Linux devices with Chromium), talking to the Knack App and force a refresh in case of a crash. Works well.

Norm

[Next page](https://forums.knack.com/t/auto-refreshing-tables/9675.md?page=2)
