Handle the Related Events

The List widget fires the selectionChanged event when an item is selected or when the selection is cancelled. The widget also fires the selectAllValueChanged event when the "Select All" check box has changed its value. If the functions that handle these events are not going to be changed during the lifetime of the widget, assign them to the corresponding onEventName options when you configure the widget.

JavaScript
$(function () {
    $("#listContainer").dxList({
        // ...
        onSelectionChanged: function(e) {
            var addedItems = e.addedItems;
            var removedItems = e.removedItems;
            // Handler of the "selectionChanged" event
        },
        onSelectAllValueChanged: function(e) {
            var newCheckBoxValue = e.value;
            // Handler of the "selectAllValueChanged" event
        }
    });
});

View Demo

If you are going to change the event handlers at runtime, or if you need to attach several handlers to a single event, subscribe to this event using the on(eventName, eventHandler) method.

JavaScript
var selectionChangedEventHandler1 = function(e) {
    // First handler of the "selectionChanged" event
};

var selectionChangedEventHandler2 = function(e) {
    // Second handler of the "selectionChanged" event
};

$("#listContainer").dxList("instance")
    .on("selectionChanged", selectionChangedEventHandler1)
    .on("selectionChanged", selectionChangedEventHandler2);
See Also