Skip to content

How to use selectNodeById? #11

@elasticfrog

Description

@elasticfrog

Hi - thank you for making this very useful repository!

I am sorry to ask for advice about coding - I am not very competent, and am stuck on something and wondered if I could ask for your guidance please?

I have this example tree code, on Codepen.

It loops through the tree data and outputs the info as per the demo.

I would l like to add links to the breadcrumb menu items, and also the headings returned in the main content window, which would mean the user could click on a link and have the code return data only for that node.

For example - this is the tree definition:

const myTreeData33 = [
  {
    id: "0",
    name: "All Records",
    type: "all",
    selected: "true",
    children: [
      {
        id: "1",
        name: "Sample category",
        type: "category",
        children: [
          {
            id: "1.1",
            name: "An example subcategory",
            type: "subcategory",
            category: "Sample category",
            children: [
              {
                id: "1.1.1",
                name: "Details about the item",
                type: "item",
                category: "Sample category",
                subcategory: "An example subcategory"
              }
            ]
          }
        ]
      }
    ]
  }
];

Presumably the selectNodeById method must be used, where the id is passed to it?

However, I am not sure of the logic or syntax re. how to change the code so that if a link is clicked, instead of following the onSelectionChange it'd follow selectNodeById instead?

If you have time to provide a pointer in the right direction please I would appreciate it very much.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions