Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Errors and unexpected behavior with selectable tree

ikan_nak priority asked 7 months ago


Expected behavior

I have a Javascript treeView with the selectable option enabled that doesn't quite work the way I expect it to. Note that this tree has both checkboxes and icons using an i tag. The tree is expected to only open and collapse nodes if I press the toggle arrows, and I expect checking and unchecking nodes to check all checkbox nodes below it, but to mark parent nodes as "indeterminate" if not all elements are checked.

Actual behavior

Checking and unchecking a node will open and collapse the relevant node instead of only changing the checked status of the node and and any related nodes, making the tree harder to navigate. Checking a node will check all child nodes, but it won't mark the nodes above it as indeterminate or even change their checked status at all unless it's the last child element of that node to be checked. If not all child elements of a node are checked, the parent node will not be checked instead of an indeterminate state. Finally, the TreeView occasionally throw the following exception in the Javascript console when checking or unchecking a node:

all.min.js:52 
 Uncaught 
TypeError: Cannot read properties of null (reading 'hide')
    at all.min.js:52:61263
    at Array.forEach (<anonymous>)
    at HTMLUListElement.<anonymous> (all.min.js:52:61216)
    at HTMLUListElement.t (all.min.js:52:51591)
    at Object.trigger (mdb.umd.min.js:20:12569)
    at To.hide (mdb.umd.min.js:20:89679)
    at To.toggle (mdb.umd.min.js:20:88745)
    at mdb.umd.min.js:44:77876
    at Array.forEach (<anonymous>)
    at HTMLAnchorElement.<anonymous> (mdb.umd.min.js:44:77826)
(anonymous) @   all.min.js:52
(anonymous) @   all.min.js:52
t   @   all.min.js:52
trigger @   mdb.umd.min.js:20
hide    @   mdb.umd.min.js:20
toggle  @   mdb.umd.min.js:20
(anonymous) @   mdb.umd.min.js:44
(anonymous) @   mdb.umd.min.js:44
s   @   mdb.umd.min.js:20  

Additional support question

Is there a way to get a list of all the selected items of a selectable tree during an event that's not triggered by the tree? I want to get this list when I click a button, but the API reference in the documentation is inconclusive.

Resources (screenshots, code snippets etc.)

Below is a code snippet

https://mdbootstrap.com/snippets/standard/ikan_nak/6117650


Grzegorz Bujański staff answered 7 months ago


Thanks for reporting. We will fix it as soon as possible


ikan_nak priority commented 7 months ago

Thanks for the quick answer. does "it" refer to just the error it throws, or also the unexpected open/close behavior when selecting tree items? And do you have an answer to the additional support question?



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 7.2.0
  • Device: Desktop computer
  • Browser: Edge
  • OS: Windows 11
  • Provided sample code: No
  • Provided link: Yes