vakata / jstree

jquery tree plugin
http://jstree.com
MIT License
5.15k stars 1.38k forks source link

select_all function ignores disabled state of items. #2658

Closed maxiz closed 1 year ago

maxiz commented 2 years ago

I have a tree with some disabled nodes that are unselected. When I used select_all function to select all active nodes, I expected the disabled nodes to remain unselected. However, it seems select_all ignores the disabled state and selects all nodes. Maybe there should be a parameter to indicate whether or not to ignore disabled nodes. A separate function might be a better solution to prevent breaking existing code.

Line 3352 in jstree.js this._data.core.selected = this._model.data[$.jstree.root].children_d.concat();

Changing it to filter out disabled nodes will fix the issue.

vakata commented 1 year ago

You can add this to your code: https://github.com/vakata/jstree/blob/master/src/misc.js#L724

Then configure it accordingly:

    $('#jstree').jstree({
        plugins : [ ... ,'select_all'],
        select_all : { disabled : false, hidden : false },
        ...