Ticket Q445431
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

How to implement auto refresh functionality on the Web

Auto-Refresh ListView without closing current popup

created 12 years ago

I need to automatically refresh a list view in the web app every 60 seconds or so. I used much of the code posted by Konstantin at the very end of http://www.devexpress.com/Support/Center/p/B220604.aspx because I wanted this to be done using partial postbacks.

I had to make some changes because it wasn't working 100% for me - the timer would sometimes continue ticking and keep causing the partial postbacks even when I've navigated to a DetailView. In addition to the snippet

C#
protected override void OnDeactivated() { WebWindow.CurrentRequestWindow.RegisterClientScript("DisableTimer", "window.timer.Stop();"); base.OnDeactivated();

}

I also tried adding timer.SetEnabled(false), setting the timer's server-side enabled property to false, removing the timer for the update panel, but this would still continue. In the end, I added a new DetailViewController which, on activation, set's the timer's client-side callback handler to just function(s,e){}. This worked.

However, the issue I have now is that when the timer is correctly refreshing the ListView, if the ListView has an open popup and a refresh happens, the popup goes away along with data entered in the popup.

Is there a way to stop the timer when a popup occurs in the web app, or is there an otherwise better way to automatically refresh the ListView?

Comments (1)
Anatol (DevExpress) 12 years ago

    Thank you for contacting us. We will need additional time to research this problem. We will post an answer as soon as we can.

    Answers

    created 12 years ago (modified 11 years ago)

    Hello Mark,
    Your solutions (both server and client side) look fine to me. In fact, we even suggested the same approaches in other tickets.
    If you are talking about popups created with the help of the ASPxPopupControl, then this control provides both client-side and server side means for determining the number of opened windows.
    I hope you can use this solution here and cancel the refresh accordingly. I have attached a complete example that shows how to use the client-side means (window.ActivePopupControls.length == 0) to accomplish your task. It seems to be the best option here, because you can do things in a single controller.

      Show previous comments (14)

        Thank you Dennis,
        Your code doesn't work for DashboardViews. In fact when I use your code for dashboard views, I encounter an error indicating there are multiple TimerHolder to return using page.FindControl("TimerHolder").
        I've made some changes to your code (which is attached) to support auto refresh for dashboard views. Can you change it in a way it can be applied both for ListViews and DashboardViews?

        Dennis Garavsky (DevExpress) 11 years ago

          I will check your modified code and let you know my results. Please stay tuned.

          Dennis Garavsky (DevExpress) 11 years ago

            @Sine: I have described a universal solution in the How to automatically refresh data in a View after a certain period of time on the Web article. I hope this helps.

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.