JavaScript code to refresh page and or telerik gri

2019-07-21 01:36发布

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.

6条回答
老娘就宠你
2楼-- · 2019-07-21 02:16

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.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-07-21 02:18

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.

查看更多
forever°为你锁心
4楼-- · 2019-07-21 02:23

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;
查看更多
狗以群分
5楼-- · 2019-07-21 02:25

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>   
查看更多
叛逆
6楼-- · 2019-07-21 02:26
    setTimeout(function(){
      window.location.reload();
   },300000);
查看更多
等我变得足够好
7楼-- · 2019-07-21 02:34

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);
查看更多
登录 后发表回答