tree onSelectChange when all the items are selected

Hi, is it possible to trigger the onSelectChange event of the tree only when all items are selected and not for each one of them when I select the items with the[…]) method?

Here is a snippet to show you what i would like to be the result:

try to check selecteds length

    onSelectChange: function() {
      var selected_ids = $$("tree").getSelectedId(true);

but in this way it works only if I select all the items.

In my snippet I select 3 out of 6 total items, in this case I don’t see any message.

Beside, in my real use case, i don’t know how many items I will select, it depends on user actions.

check this workaround

Thanks, this is what I needed!