A newer version of this page is available. Switch to the current version.

Change Options

IMPORTANT
According to Stack Overflow Trends, MVVM frameworks such as Angular, Vue, and React became more popular than Knockout in recent years. DevExtreme will continue to support Knockout but we recommend that you use one of these frameworks in your new projects.

To change a widget option, declare its value an observable.

JavaScript
var viewModel = {
    checkBoxOptions: {
        // ...
        value: ko.observable(true)
    }
};

viewModel.changeObservables = function () {
    viewModel.checkBoxOptions.value(false);
};

ko.applyBindings(viewModel);

Now, if you change an observable in code, the widget will receive the changes and update the UI. And vice versa, if a user changes something in the UI, the observable gets updated.

NOTE
Options containing array and specified on the second (or further) level of the configuration object cannot be made observable.
See Also