Client-Side API
- 3 minutes to read
The ASPxTrackBar control provides you with a comprehensive client-side API. This API is implemented using JavaScript and is exposed via the ASPxClientTrackBar object. The ASPxClientTrackBar object serves as a client-side equivalent of the ASPxTrackBar control.
ASPxClientTrackBar implements the functionality that allows you to perform the following track bar related actions on the client.
- Manipulate drag handle positions
- Respond to an end-user changing drag handle positions
- Obtain track bar item information
In addition, ASPxClientTrackBar exposes the common client API, which it inherits from its direct ansestor - ASPxClientEdit.
Refer to Client-Side Functionality Overview to learn more about DevExpress client-side model implementation.
Manipulate drag handle positions
Depending upon the selection mode applied, you can use different client methods to obtain or change drag handle positions on the client side.
Single value selection mode
You can operate the position of a single (main) drag handle, using the following methods.
Method Description ASPxClientTrackBar.GetPosition Gets a drag handle position. ASPxClientTrackBar.SetPosition Specifies a drag handle position. Range selection mode
You can operate the positions of the main and secondary drag handles using the methods listed below.
Method Description ASPxClientTrackBar.GetPositionStart Returns the main drag handle position. ASPxClientTrackBar.GetPositionEnd Returns the secondary drag handle position. ASPxClientTrackBar.SetPositionStart Specifies the main drag handle position. ASPxClientTrackBar.SetPositionEnd Specifies the secondary drag handle position.
Respond to an end-user changing drag handle positions
Each time an end-user manipulates ASPxTrackBar‘s elements on the client, you can provide a proper and immediate response by handling specific exposed client events. The available client events fall into the following two categories.
Selection changing
You can respond to any selection change made by an end-user and even cancel the user action by using the following events (refer to Value Selection to learn how end-users can change the editor’s selection).
Event Description ASPxClientTrackBar.PositionChanging Fires on the client side before a track bar position is changed and allows you to cancel the action. ASPxClientTrackBar.PositionChanged Fires after the editor’s position has been changed. Handle dragging
You can independently respond to an end-user being dragged by a drag handle by using the following events.
Event Description ASPxClientTrackBar.TrackStart Occurs on the client-side when an end-user presses a drag handle and moves it. ASPxClientTrackBar.Track Occurs on the client-side when an end-user moves a cursor while the drag handle is held down. ASPxClientTrackBar.TrackEnd Occurs on the client-side when an end-user releases a drag handle after moving it.
Obtain track bar item information
If ASPxTrackBar works in an items mode, you can use specific item-related methods on the client. They allow you to obtain the following information.
Collection-related info (item index and total count)
Use the following methods to get either the total number of items in the ASPxTrackBar.Items collection or the index of a specific item.
Event Description ASPxClientTrackBar.GetItemCount Returns the number of the track bar items that are maintained by the item collection. ASPxClientTrackBar.GetItemIndexByValue Returns a track bar item index by the item’s value. Individual item settings
You can obtain settings, such as text, value and tooltip text of a particular item specified by its collection index.
Event Description ASPxClientTrackBar.GetItemText Returns a track bar item text. ASPxClientTrackBar.GetItemValue Returns a track bar item’s associated value. ASPxClientTrackBar.GetItemToolTip Returns a track bar item’s tooltip text.
To learn more on how to use ASPxTrackBar‘s client API, refer to the following example.