EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: battlezad on March 23, 2016, 04:22:52 AM



Title: datagrid data triggers reload
Post by: battlezad on March 23, 2016, 04:22:52 AM
if I set datagrid data like this

var IntervalRefresh = 0;
var refreshInterval = 60;

setInterval(function() {
   $.post('get_db_statuses.php', {}, lpOnComplete, 'json');
}, refreshInterval * 1000);


var lpOnComplete = function(response)
{
   IntervalRefresh = 1;
   if(response != null)
   {
      $('#statuses').datagrid({
         data: response
      });
      refreshInterval = 60;
   }
};

it triggers also datagrid reload (?).

Now I have tackled it with

...
onBeforeLoad: function(data)
{
   if(IntervalRefresh == 1) return false;
}

Do I have something wrong in my options?



Title: Re: datagrid data triggers reload
Post by: jarry on March 23, 2016, 08:51:39 AM
Please try this code instead.
Code:
var lpOnComplete = function(response) 
{
   IntervalRefresh = 1;
   if(response != null)
   {
      $('#statuses').datagrid('loadData',response);
      refreshInterval = 60;
   }
};