Ticket T221422
Visible to All Users

dxTreeView clearSelection

created 10 years ago

I am trying to deselect items in a dxTreeView when a button is clicked.

Because dxTreeView doesn't have a clearSelection() method like dxDataGrid , i tried to use option() method to set a empty array to the selectedItems configuration like this "option('selectedItems', []) " and then to use the repaint() method.

I receive the following error when call the repaint() method:
Uncaught Error: E0009 - Component 'dxCheckBox' has not been initialized for an element. See:
http://js.devexpress.com/error/14_2/E0009

What other alternative i have to clear the selection of the dxTreeView ?

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

Hello Daniel,

The selectedItems option is deprecated. dxTreeView provides the selectItem and unselectItem methods to programmatically change the item selection. These methods accept a DOM element corresponding to a tree view item or data item as parameter. Below is an example of the function that deselects all items in the tree view. A complete example is attached to this message.

JavaScript
function clearSelection() { treeView.beginUpdate(); $.each(treeView.option('items'), function() { treeView.unselectItem(this); }); treeView.endUpdate(); }

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.