最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - JavaScript code to refresh page and or telerik grid - Stack Overflow

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论