Your search did not match any results.
Progress Bar

Progress Bar

Documentation

The ProgressBar is a UI component that shows current progress.

Backend API
Copy to CodePen
Apply
Reset
window.onload = function () { const progressBarValue = ko.observable(0); const buttonText = ko.observable('Start progress'); let seconds = 10; let inProgress = false; let intervalId; function setCurrentStatus() { progressBarValue((10 - seconds) * 10); $('#timer').text((`0${seconds}`).slice(-2)); } function timer() { seconds -= 1; setCurrentStatus(); if (seconds === 0) { clearInterval(intervalId); seconds = 10; } } const viewModel = { progressBarOptions: { min: 0, max: 100, value: progressBarValue, width: '90%', statusFormat(value) { return `Loading: ${value * 100}%`; }, onComplete(e) { inProgress = false; buttonText('Restart progress'); e.element.addClass('complete'); }, }, buttonOptions: { text: buttonText, width: 200, onClick() { $('#progressBarStatus').removeClass('complete'); if (inProgress) { buttonText('Continue progress'); clearInterval(intervalId); } else { buttonText('Stop progress'); setCurrentStatus(); intervalId = setInterval(timer, 1000); } inProgress = !inProgress; }, }, }; ko.applyBindings(viewModel, document.getElementById('progress-bar')); };
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/21.2.3/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/21.2.3/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/21.2.3/js/dx.all.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div class="form" id="progress-bar"> <div id="progress-button" data-bind="dxButton: buttonOptions"></div> <div class="progress-info"> Time left 00:00:<span id="timer">10</span> </div> <div id="progress"> <div id="progressBarStatus" data-bind="dxProgressBar: progressBarOptions"></div> </div> </div> </div> </body> </html>
.form { padding: 20% 0; text-align: center; } #progress-button { margin-bottom: 20px; } #progressBarStatus { display: inline-block; } .complete .dx-progressbar-range { background-color: green; }