erhanfirat / combo-tree

ComboTree is a jQuery Plugin which is a combobox item with tree structured data list and multi/single selection options and more.
MIT License
79 stars 67 forks source link

selecting all sub items when selecting the parent. #10

Closed harishksoft closed 4 years ago

harishksoft commented 5 years ago

@kirlisakal is it possible to select all the sub-items when selecting the parent item? something like this https://www.jqueryscript.net/demo/Collapsible-Tree-View-Checkboxes-jQuery-hummingbird/

and need to get all selected checkbox ids in the getselecteditem variable

sancel22 commented 5 years ago

@harishksoft while waiting for this update, For the meantime I'm doing it externally.

            $.each(JSON.parse(target_keys), function(index, target) {
                $('span[data-id="'+target+'"]').on('click', function() {
                    var checkBoxes = $(this).parent().find('ul input:checkbox');
                    var isCheck = $(this).find('input').prop('checked');
                    $.each(checkBoxes, function(i, cTarget) {
                        if (isCheck !== $(cTarget).prop('checked')) {
                            $(cTarget).parent().click();
                        }
                    });
                });
            })
erhanfirat commented 4 years ago

You can achieve this by setting cascadeSelect option to true. Thanks...