ProgressBar
- 4 minutes to read
ProgressBar represents a progress bar control that enables you to visually indicate the progress of a lengthy operation or operation rate, etc. A progress bar is typically used when an application performs tasks such as uploading files or deleting data records.
Implementation Details
ProgressBar is realized by the ProgressBarExtension class. Its instance can be accessed via the ExtensionsFactory.ProgressBar helper method, which is used to add a ProgressBar extension to a view. This method’s parameter provides access to the ProgressBar‘s settings implemented by the ProgressBarSettings class, allowing you to fully customize the extension.
The ProgressBar‘s client counterpart is represented by the ASPxClientProgressBar object.
Declaration
ProgressBar can be added to a view in the following manner.
View code (ASPX):
<%
Html.DevExpress().ProgressBar(
settings => {
settings.Name = "progressBar1";
settings.Properties.Minimum = 0;
settings.Properties.Maximum = 10;
settings.Position = 3;
settings.Properties.ShowPosition = true;
settings.Width = 150;
}
)
.Render();
%>
View code (Razor):
@Html.DevExpress().ProgressBar(
settings => {
settings.Name = "progressBar1";
settings.Properties.Minimum = 0;
settings.Properties.Maximum = 10;
settings.Position = 3;
settings.Properties.ShowPosition = true;
settings.Width = 150;
}).GetHtml()
Note
The Partial View should contain only the extension’s code.
The code result is demonstrated in the image below.
#№ Main Features
The ProgressBar extension allows you to visually indicate a lengthy operation progress, operation rate, etc.
The ProgressBar offers the following features.
The Capability to Limit an Indicated Range
The ProgressBarSettings.Properties.Minimum (ProgressBarProperties.Minimum) and ProgressBarSettings.Properties.Maximum (ProgressBarProperties.Maximum) properties define a range of values that represent the progress of an operation. The Minimum property is typically set to 0, and the Maximum property is typically set to a value indicating the completion of a task. For instance, to properly display progress when uploading a group of files, the Maximum property could be set to the total number of files to be uploaded or to their total length.
The ProgressBarSettings.Position property defines the progress that the application has made toward completing the operation. Position property’s value lies in the range defined by the Minimum and Maximum property values.
Optional Text Display
The ProgressBarSettings.ShowPosition property defines whether or not the progress bar displays the text representation of a progress value. The ProgressBarSettings.DisplayMode property defines whether the progress bar displays the progress value in a percentage or a position view. The value displayed by the progress bar control only approximates the current value of the Position property.
ProgressBar View
Affected Properties
ShowPosition = False
Minimum = 0
Maximum = 50
Position = 20
ShowPosition = True
DisplayMode = Percentage
Minimum = 0
Maximum = 50
Position = 20
ShowPosition = True
DisplayMode = Position
Minimum = 0
Maximum = 50
Position = 20
Customizable Appearance
The ProgressBar extension supports appearance customization via the standard extension properties. You can define the progress bar indicator’s appearance via the ProgressBarSettings.Properties.IndicatorStyle (ProgressBarProperties.IndicatorStyle) property.
You can customize the extension appearance using predefined built-in visual themes. See this topic to learn more: Applying Themes.
Full-Featured Client-Side API
The ProgressBar provides you with a comprehensive client-side API. This API is implemented using JavaScript and is exposed via the ASPxClientProgressBar object. The ASPxClientProgressBar object serves as a client-side equivalent of the ProgressBar extension.
You can operate with the editor values using the following methods.
Method Description ASPxClientProgressBar.GetMaximum Gets the maximum range value of the progress bar. ASPxClientProgressBar.GetMinimum Gets the minimum range value of the progress bar. ASPxClientProgressBar.GetPercent Sets the percentage representation of the progress position. ASPxClientProgressBar.GetPosition Gets the position of the operation’s progress. ASPxClientProgressBar.SetMaximum Sets the maximum range value of the progress bar. ASPxClientProgressBar.SetMinimum Sets the minimum range value of the progress bar. ASPxClientProgressBar.SetMinMaxValues Sets the minimum and maximum range values of the progress bar. ASPxClientProgressBar.SetPosition Sets the position of the operation’s progress.