c1.documentReady(function () {
var theGridGif = wijmo.Control.getControl(
'#theGridGif'
);
var theSpinnerGif = document.getElementById(
'theSpinnerGif'
);
document.getElementById(
'btn-load-gif'
).addEventListener(
'click'
, function () {
theGridGif.isDisabled =
true
;
theGridGif.itemsSource =
null
;
theGridGif.hostElement.insertBefore(theSpinnerGif, theGridGif.hostElement.firstChild);
getData(function (data) {
theGridGif.itemsSource = data;
theGridGif.isDisabled =
false
;
theSpinnerGif.parentElement.removeChild(theSpinnerGif);
}, 3000);
})
var theGridGauge = wijmo.Control.getControl(
'#theGridGauge'
);
document.getElementById(
'btn-load-gauge'
).addEventListener(
'click'
, function () {
theGridGauge.itemsSource =
null
;
setSpinner(theGridGauge,
true
);
getData(function (data) {
theGridGauge.itemsSource = data;
setSpinner(theGridGauge,
false
);
}, 3000);
});
var theSpinnerInterval;
var theSpinnerGauge = wijmo.Control.getControl(
'#theSpinnerGauge'
);
function setSpinner(grid, on) {
if
(theSpinnerInterval) {
clearInterval(theSpinnerInterval);
theSpinnerInterval =
null
;
}
var spinner = theSpinnerGauge.hostElement;
if
(on) {
grid.isDisabled =
true
;
grid.hostElement.insertBefore(spinner, grid.hostElement.firstChild);
theSpinnerGauge.invalidate();
theSpinnerGauge.value = 0;
theSpinnerInterval = setInterval(function () {
theSpinnerGauge.value = (theSpinnerGauge.value + 1) % 100;
}, 50);
}
else
{
grid.isDisabled =
false
;
spinner.parentElement.removeChild(spinner);
}
}
function getData(callback, delay) {
var countries =
'US,UK,China,Germany,India'
.split(
','
),
data = [];
for
(var i = 0; i < 1000; i++) {
data.push({
id: i,
country: countries[i % countries.length],
sales: Math.random() * 1000,
downloads: Math.random() * 10000,
});
}
setTimeout(function () {
callback(data)
}, delay);
}
});