linjingming / sim-tree

一个操作简单的基于jquery的树展示插件,支持异步展示子节点
MIT License
24 stars 3 forks source link

When selected parent element, disabled child nodes are also getting selected #4

Open raghuveer-kurdi opened 5 years ago

raghuveer-kurdi commented 5 years ago

i have below structrue var myData = [{ "id": '1', "pid": '', "name": "Root", "disabled": true }, { "id": '1.1', "pid": '1', // parent ID "name": "Level 1" }, { "id": '1.1.1', "pid": '1.1', // parent ID "name": "Level 2", "disabled": true }, { "id": '1.1.1.1', "pid": '1.1', // parent ID "name": "Level 2" }];

In the above structure, Level 1 can be selectable and Level 2 with id 1.1.1.1 is selectable.

If directly parent node is selected, i.e 1.1, even 1.1.1 obj is getting selected, but it should not as its disabled.

raghuveer-kurdi commented 5 years ago

On the doCheck method of simTree.js file, i have added the below line of code.

@line no 351. if ($li.hasClass('disabled')) return;

This works for me, please review.

raghuveer-kurdi commented 5 years ago

I don't think its a proper fix, it worked initially. But when we have intermediate parents as disabled, but childs are enabled, selection doesn't work properly.