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

AJAX-refreshing progressArea in grid

1 Answer 96 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Oscar
Top achievements
Rank 1
Oscar asked on 16 Jul 2012, 08:06 PM
Hello
I have a progress monitoring screen with a radGrid that lists processes.
One of the grid columns contains a progressArea that shows process progress (from 0 to 100%) (see attachment)
To refresh the page I use the following

Page.ClientScript.RegisterStartupScript(

Me.GetType(), "refresh", "window.setTimeout('window.location.reload(true)',10000);", True)


This causes the entire page to reload every 10 seconds, which is annoying,  I want just the progressareas to refresh, but cannot find how.
Thanks for any help

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 18 Jul 2012, 02:00 PM
Hello Oscar,

I suggest you to use setInterval() method to perform AJAX request on given interval. You could do this by applying the following JavaScript:
JavaScript:
<telerik:RadCodeBlock runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            setInterval(alertMessage, 1000);
        });
 
        function alertMessage() {
            $find('<%=RadAjaxManager1.ClientID %>').ajaxRequest("refreshLabel");
        };
     </script>
</telerik:RadCodeBlock>

You have to set the OnAjaxRequest event handler and update the RadGrid control:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
            </UpdatedControls>
 
       </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

In code behind you shoud find the control which you want to update and make the appropriate changes. 
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
    if (e.Argument == "refreshLabel")
    {
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
        {
            Label label = item.FindControl("Label1") as Label;
            label.Text = DateTime.Now.ToString();
        }
    }
}

I prepared a small sample and attached it to this thread. I hope this helps.

Kind regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
Oscar
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or