Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2500
How to multiselect children in tree node using Shift key
posted

In an igCombo you can select one item in the dropdown, then hold down the Shift key while selecting another item, and the first item and last item and all items in between are selected.

I am using an igTree with checkboxes. After expanding a particular node I would like to select multiple children using a similar method - ie. selecting one item, then selecting another under the same node while holding down the shift key, then all in between are automatically selected.

Is this functionality available for an igTree, and it so, how would it be implemented?

Parents
  • 17590
    Offline posted

    Hello Ray,

    Thank you for posting in our community.

    At this point we do not provide out of the box way to select range of nodes while holding "Shift" key.

    Alternatively, what I can suggest is handling selectionChanging event of the igTree where you have a reference to both currently selected and the newly selected nodes. Additionally, via the ui argument you can get reference whether the selection was changed while Shift key was pressed. If the Shift key was pressed and you calculate the nodes in between the currently selected and newly selected once you can loop trough the delta collection and manually check them using checkNode method. For example:

    selectionChanging: function(evt, ui) {
    								var currentNodes = ui.selectedNodes,
    									newlySelected = ui.newNodes,
    									nodesToSelect = //TODO Find all noodes between the currently and the newly selected;
    											if(evt.originalEvent.shiftKey) {
    												nodesToSelect.each(function(index){
    													ui.owner.checkNode(nodesToSelect[i]);
    												})
    											}
    								},

    Hope you will find this approach helpful.
    Please let me know if you need any further assistance with this matter.

Reply Children