All docs
V19.2
24.1
The page you are viewing does not exist in version 24.1.
23.2
The page you are viewing does not exist in version 23.2.
23.1
The page you are viewing does not exist in version 23.1.
22.2
The page you are viewing does not exist in version 22.2.
22.1
The page you are viewing does not exist in version 22.1.
21.2
The page you are viewing does not exist in version 21.2.
21.1
The page you are viewing does not exist in version 21.1.
20.2
The page you are viewing does not exist in version 20.2.
20.1
The page you are viewing does not exist in version 20.1.
19.2
19.1
18.2
18.1
17.2
The page you are viewing does not exist in version 17.2.
A newer version of this page is available. Switch to the current version.

DevExtreme jQuery - Get a Widget Instance

Use the following code to get a widget instance:

JavaScript
var chartInstance = $("#chartContainer").dxChart("instance");

If the widget is not yet instantiated, this code throws an E0009 exception that you can handle with a try...catch block:

JavaScript
try {
    var chartInstance = $("#chartContainer").dxChart("instance");
}
catch (err) {
    alert("Exception handled: " + err.message);
}

Instead of the exception, you can get a truthy or falsy value that can be used in conditional statements. To do this, call the widget class's static getInstance(element) method. This method returns undefined if the widget is not instantiated for the element:

JavaScript
var element = document.getElementById("chartContainer");
var chartInstance = DevExpress.viz.dxChart.getInstance(element);
if (chartInstance) {
    // Your code goes here
}
See Also