Toast Configuration

An object defining configuration options for the dxToast widget.

animation

An object that defines the animation options of the widget.

Type: animation configuration
Default Value: { show: { type: "fade", duration: 400, to: 1 }, hide: { type: "fade", duration: 400, to: 0 } }
Default for android below version 4: { show: { type: "fade", duration: 400 }, hide: { type: "fade", duration: 400, to: { opacity: 0 }, from: { opacity: 1 } } }

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Show toast', clickAction: showToast }"></div>
<div class="dx-fieldset">
  <div class="dx-field">
    <div style="width: 60%" class="dx-field-label">Animation Type</div>
    <div style="width: 40%" class="dx-field-value" data-bind="dxLookup: {
      dataSource: animationTypes,
      value: animationType,
      valueChangeAction: typeChanged
    }"></div>
  </div>
</div>
<div id="toastContainer" data-bind="dxToast: { 
  message: 'Toast message', 
  animation: animationConfig
}"></div>
animationTypes = [
  "fade",
  "pop",
  "slide"
];
animationType = ko.observable(animationTypes[0]);
animationConfig = ko.observable({});
typeChanged = function () {
  switch (animationType()) {
    case "slide":
      animationConfig({
        show: { type: "slide", from: { opacity: 1, top: 200 }, to: { top: 0 } },
        hide: { type: "slide", from: { top: 0 }, to: { top: 200 } }
      });
      break;
    case "pop":
      animationConfig({
        show: { type: "pop", from: { opacity: 1, scale: 0 }, to: { scale: 1 } },
        hide: { type: "pop", from: { scale: 1 }, to: { scale: 0 } }
      });
      break;
    case "fade":
      animationConfig({
        show: { type: "fade", from: 0, to: 1 },
        hide: { type: "fade", from: 1, to: 0 }
      });
      break;
    default:
      animationConfig({});
  }
}
showToast = function () {
  $("#toastContainer").dxToast("instance").show();
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

clickAction

An action performed when a widget is clicked.

Type: Action
Default Value: null

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div id="toastContainer" data-bind="dxToast: {
  message: 'Click this toast',
  type: 'Success',
  displayTime: 5000,
  clickAction: processClick
}"></div>
showToast = function () {
  $("#toastContainer").dxToast('instance').show();
};
processClick = function () {
  DevExpress.ui.dialog.alert("The widget has been clicked", "Click notification");
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

closeOnOutsideClick

A Boolean value specifying whether or not the widget is closed if a user clicks outside of the overlaying window.

Type: Boolean
Default Value: false

contentReadyAction

An action performed when widget content is ready.

Type: Action
Default Value: null

deferRendering

Specifies whether widget content is rendered when the widget is shown or when rendering the widget.

Type: Boolean
Default Value: true

If this option is set to true, widget content is rendered when showing the widget. Otherwise, widget content is rendered when rendering the widget.

displayTime

The time span in milliseconds during which the dxToast widget is visible.

Type: Number
Default Value: 2000

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div class="dx-fieldset">
  <div class="dx-field">
    <div class="dx-field-label">Display Time</div>
    <div class="dx-field-value" data-bind="text: displayTimeValue"></div>
    <div data-bind="dxSlider: { max: 5000, min: 0, value: displayTimeValue }"></div>
  </div>
</div>
<div id="toastContainer" data-bind="dxToast: { message: 'The toast message', type: 'success', displayTime: displayTimeValue }"></div>
displayTimeValue = ko.observable(2000);
showToast = function () {
  $("#toastContainer").dxToast('instance').show();
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

height

The height of the widget in pixels.

Type: Number|String|function
Return Value: Number|String
The widget height.
Default Value: 'auto'

The option can hold a value of the following types.

  • numeric - the height of the widget in pixels
  • string - a CSS measurement of the widget height (e.g., "55px", "80%", "auto" and "inherit")
  • function - a function returning the widget height (e.g., height:function(){ return baseHeight - 10 + "%"; })

hiddenAction

An action performed after the widget is hidden.

Type: Action
Default Value: null

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div data-bind="dxToast: {
    message: 'My toast',
    visible: toastVisible,
    displayTime: 2000,
    hiddenAction: processHiding
}"></div>
toastVisible = ko.observable(false);
showToast = function () {
    toastVisible(true);
};
processHiding = function () {
  DevExpress.ui.dialog.alert("The widget has been hidden", "Action executed");
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

hidingAction

An action performed before hiding the widget.

Type: Action
Default Value: null

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div data-bind="dxToast: {
    message: 'My toast',
    visible: toastVisible,
    displayTime: 2000,
    hidingAction: processHiding
}"></div>
toastVisible = ko.observable(false);
showToast = function () {
    toastVisible(true);
};
processHiding = function () {
  DevExpress.ui.dialog.alert("The widget is being hidden", "Action executed");
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

message

The dxToast message text.

Type: String
Default Value: ""

position

An object defining widget positioning options.

Type: position configuration
Default Value: { my: 'bottom center', at: 'bottom center', of: window, offset: '0 -20' }
Default for windows 8: { my: "top center", at: "top center", of: window, offset: "0 0" }

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Show toast', clickAction: showToast }"></div>
<p style="text-align:center"><b>Position</b></p>
<div class="dx-fieldset">
  <div class="dx-field">
    <div class="dx-field-label">my</div>
    <div class="dx-field-value" data-bind="dxLookup: { dataSource: positionValues, value: myValue }"></div>
  </div>
  <div class="dx-field">
    <div class="dx-field-label">at</div>
    <div class="dx-field-value" data-bind="dxLookup: { dataSource: positionValues, value:atValue }"></div>
  </div>
  <div class="dx-field">
    <div class="dx-field-label">offset</div>
    <div class="dx-field-value" data-bind="dxTextBox: { value: offsetValue }"></div>
  </div>
</div>
<div id="targetElement"></div>
<div id="toastContainer" data-bind="dxToast: { 
  message: 'Toast message', 
  displayTime:2000, 
  position: {
    my: myValue(),
    at: atValue(),
    of: $('#targetElement'),
    offset: offsetValue()
  }
}"></div>
atValue = ko.observable("bottom");
myValue = ko.observable("bottom");
offsetValue = ko.observable("0 0");
showToast = function () {
  $("#toastContainer").dxToast("instance").show();
};
positionValues = [
  "left top",
  "top",
  "right top",
  "right",
  "right bottom",
  "bottom",
  "left bottom",
  "left",
  "center"
];
body{
  text-align: center;
}
.button{
  margin: 10px;
}
#targetElement {
  display: inline-block;
  width: 80%;
  height: 170px;
  border-style: solid;
  background-color: lightgreen;
}

shading

A Boolean value specifying whether or not the main screen is inactive while the overlay is active.

Type: Boolean
Default Value: false

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div class="dx-fieldset">
  <div class="dx-field">
    <div class="dx-field-label">Shading</div>
    <div class="dx-field-value" data-bind="dxCheckBox: { checked: enableShading }"></div>
  </div>
</div>
<div id="toastContainer" data-bind="dxToast: { message: 'The toast message', type: 'success', displayTime: 1000, shading: enableShading }"></div>
enableShading = ko.observable(false);
showToast = function () {
  $("#toastContainer").dxToast('instance').show();
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

shadingColor

Specifies the shading color.

Type: String
Default Value: ''

This option makes sense only if the shading option is set to true.

showingAction

An action performed before showing the overlay.

Type: Action
Default Value: null

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div data-bind="dxToast: {
    message: 'My toast',
    visible: toastVisible,
    displayTime: 2000,
    showingAction: processShowing
}"></div>
toastVisible = ko.observable(false);
showToast = function () {
    toastVisible(true);
};
processShowing = function () {
  DevExpress.ui.dialog.alert("The widget is being shown", "Action executed");
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

shownAction

An action performed after the widget is shown.

Type: Action
Default Value: null

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Toast', clickAction: showToast }"></div>
<div data-bind="dxToast: {
    message: 'My toast',
    visible: toastVisible,
    displayTime: 2000,
    showingAction: processShowing
}"></div>
toastVisible = ko.observable(false);
showToast = function () {
    toastVisible(true);
};
processShowing = function () {
  DevExpress.ui.dialog.alert("The widget has been shown", "Action executed");
};
body{
  text-align: center;
}
.button{
  margin: 10px;
}

type

Specifies the dxToast widget type.

Type: String
Default Value: 'info'
Accepted Values: 'info'|'warning'|'error'|'success'|'custom'

The available toast types (except for "custom") only differ by the icon and background color.

If you assign "custom" to the type option, the dx-toast-custom class is applied to the widget element. Implement the appropriate CSS class to specify toast appearance.

Show Example:
jQuery
<div class="button" data-bind="dxButton: { text: 'Show toast', clickAction: showToast }"></div>
<div class="dx-fieldset">
    <div class="dx-field">
        <div class="dx-field-label">Type</div>
        <div class="dx-field-value" data-bind="dxLookup: { dataSource: toastTypes, value: currentType }"></div>
    </div>
</div>
<div id="toastContainer" data-bind="dxToast: { message: 'The toast message', type: currentType, displayTime: 3000 }">
</div>
<div id="customToastContainer" data-bind="dxToast: { type: 'custom', displayTime: 3000 }">
  The custom toast message!<br/>
  <div class="dx-icon dx-icon-toolbox"></div>
</div>
showToast = function () {
  if (currentType() == 'custom')
    $("#customToastContainer").dxToast('instance').show();
  else
    $("#toastContainer").dxToast('instance').show();
};
processClick = function () {
  DevExpress.ui.dialog.alert("The widget has been clicked", "Click notification");
};
toastTypes = [
  "info",
  "warning",
  "error",
  "success",
  "custom"
];
currentType = ko.observable(toastTypes[0]);
body{
  text-align: center;
}
.button{
  margin: 10px;
}
.dx-theme-ios .dx-toast .dx-toast-custom{
  background-color: orange;
  font-size: 28px;
}
.dx-theme-android .dx-toast .dx-toast-custom{
  background-color: #616161;
  font-size: 28px;
}
.dx-theme-win8 .dx-toast .dx-toast-custom{
  background-color: gray;
  font-size: 28px;
}
.dx-icon {
  display: inline-block;
  height: 56px;
  width: 56px;
  vertical-align: middle;
}

visible

A Boolean value specifying whether or not the widget is visible.

Type: Boolean
Default Value: false

You can show and hide the widget by changing the value of an observable variable passed to this option.

Show Example:
jQuery
<div class="dx-fieldset">
  <div class="dx-field">
    <div class="dx-field-label">Visible</div>
    <div class="dx-field-value" data-bind="dxCheckBox: { checked: toastVisible }"></div>
  </div>
</div>
<div data-bind="dxToast: {
    message: 'My toast',
    visible: toastVisible,
    displayTime: 2000
}"></div>
toastVisible = ko.observable(false);
body{
  text-align: center;
}

width

The widget width in pixels.

Type: Number|String|function
Return Value: Number|String
The widget width.
Default Value: function() {return $(window).width() * 0.8 }
Default for windows 8: function() { return $(window).width() - 20; }

The option can hold a value of the following types.

  • numeric - the widget width in pixels
  • string - a CSS measurement of the widget width (e.g., "55px", "80%", "auto" and "inherit")
  • function - the function returning the widget width (e.g., width:function(){ return baseWidth - 10 + "%"; })