admin管理员组

文章数量:1220817

I need some kind of code which will refresh the page every 5min and if not the page then just the Telerik grid displayed on it since that's all that's rly needed.

Only other thing would be if it was after 5min of no activity on the page if possible but it's not core feature.

I need some kind of code which will refresh the page every 5min and if not the page then just the Telerik grid displayed on it since that's all that's rly needed.

Only other thing would be if it was after 5min of no activity on the page if possible but it's not core feature.

Share Improve this question edited Apr 6, 2011 at 11:05 abatishchev 100k88 gold badges301 silver badges442 bronze badges asked Apr 6, 2011 at 11:01 MyziferMyzifer 1,1251 gold badge21 silver badges57 bronze badges 1
  • would be nice if whom ever down voted me explained why so I could improve/correct on what ever is wrong. – Myzifer Commented Apr 6, 2011 at 11:41
Add a comment  | 

6 Answers 6

Reset to default 6

One possibility is to use a meta refresh tag:

<meta http-equiv="refresh" content="300" />

Another possibility is to use the window.setInterval method to send periodic AJAX requests to a controller action and update the DOM:

window.setInterval(function() {
    // Send an AJAX request to a controller action which will
    // return a partial with the grid and update the DOM
    $.ajax({
        url: '/grid',
        success: function(result) {
            $('#someGridContainer').html(result);
        }
    });
}, 300000);

And to implement the idle functionality you could use the jquery idle plugin.

keep it simple, call refreshGrid() function when you need to refresh grid.

function refreshGrid() {
    if ($(".t-grid .t-refresh").exists()) {
        $(".t-grid .t-refresh").trigger('click');
    }
}

/*return true if does selected element exist.*/
(function ($) {
    $.fn.exists = function () { return jQuery(this).length > 0; }
})(jQuery);
    setTimeout(function(){
      window.location.reload();
   },300000);

If your grid is set up for ajax refreshes, then you can use something like

    <script type="text/javascript">
        $(function() {
            setInterval(function() {
                $('#GridName').data('tGrid').ajaxRequest(); 
            }, 300000);
        }); 
    </script>   

For Server Bindings Telerik Grid Just need to do the following Thing..... Just use and cheers

After any event you can call this

   var href = $('.t-refresh').attr('href');
    window.location.href = href;

If you are using Ajax or Webservice binding on the Telerik Grid, you can call the rebind() method on the grid object. That will force it to call the Select method of the binding again to get the latest data.

If you combine the rebind() call with Darin's answer of using the SetInterval method, it should give you what you are after.

本文标签: cJavaScript code to refresh page and or telerik gridStack Overflow