This is a migrated thread and some comments may be shown as answers.

Auto-refresh a grid

7 Answers 385 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Covertix
Top achievements
Rank 1
Covertix asked on 06 Nov 2014, 04:30 PM
I want to refresh my grid from client-side every 1 minute.
I use RadAjaxManager and I set my grid as "AjaxUpdatedControl".

I created a function:

    function AutoRefreshPage() {<br>        RebindTasksGrid();<br>        autoRefreshTimer = setTimeout("AutoRefreshPage()", 60000);<br>    }

which calls "RebindTasksGrid":

    function RebindTasksGrid() {<br>        var masterTable = $find("<%= rgDeployTasks.ClientID %>").get_masterTableView();<br>        masterTable.rebind();<br>    }


And I start it first on "pageLoad" function:

    function pageLoad() {<br>        AutoRefreshPage();<br>    }


The problem is that the "masterTable.rebind()" fires the "pageLoad" function over and over again and I got stuck on an infinite loop.

How can I auto-refresh a grid without loading the whole page again?

7 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 11 Nov 2014, 01:02 PM
Hello Tzach,

The best approach for this scenario is to conditionally registrar the "AutoRefreshPage()" function initially on the server PageLoad instead on the client, like this:
protected void Page_Load(object sender, EventArgs e)
   {
       if (!Page.IsPostBack)
        
       {
           ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "mykey", AutoRefreshPage(), true);     
       }
   }


Regards,
Maria Ilieva
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Covertix
Top achievements
Rank 1
answered on 12 Nov 2014, 09:03 AM
Hi Maria and Thanks!
I tried your approach, but the "AutoRefreshPage()" function is never called.
0
Covertix
Top achievements
Rank 1
answered on 16 Nov 2014, 09:17 AM
Is there any other idea please?
0
Maria Ilieva
Telerik team
answered on 17 Nov 2014, 08:22 AM
Hello Tzach,

I want to apologize as in my last post I have made a small mistake that probably is causing the function to not execute. The function name should be passed as a string like this:
protected void Page_Load(object sender, EventArgs e)
   {
       if (!Page.IsPostBack)
       {
           ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "mykey", "AutoRefreshPage()", true);
       }
   }

Give this a try and see if it works for you.

Regards,
Maria Ilieva
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Covertix
Top achievements
Rank 1
answered on 17 Nov 2014, 10:31 AM
Hi Maria,

This is not the problem, I passed it as a string (it is not compiling otherwise)..
But for some reason, it is not fired.


This is my code:

server side:
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!IsPostBack)
        {
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "mykey", "AutoRefreshPage()", true);
            //ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "mykey", "AutoRefreshPage()", true);
        }
    }


Client-side:
    function pageLoad() {
        alert("load");
    }

    function AutoRefreshPage() {
        alert("AutoRefreshPage");
        RebindTasksGrid();
        autoRefreshTimer = setTimeout("AutoRefreshPage()", 60000);
    }


I get only the "load" alert.
 



0
Covertix
Top achievements
Rank 1
answered on 19 Nov 2014, 11:51 AM
I found a solution in here:
http://demos.telerik.com/aspnet-ajax/ajax/examples/common/ajaxifytimer/defaultcs.aspx
0
Mike
Top achievements
Rank 1
answered on 16 Mar 2017, 02:35 PM

I am using the AjaxifyTimer demo.  We have a TextBox as a TemplateColumn in the Grid and on the TextChanged event, it is saving the Textbox value to database.

 

Problem is when the database value is modified, the TextChanged event is firing and saving the old value to the database.

Tags
Grid
Asked by
Covertix
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Covertix
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Share this question
or