question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Checkboxes and async loading of children

See original GitHub issue

Hi,

I am loading a tree with multiple levels with checkboxes (+4000 nodes) and I use async loading. First I got an error but after monkey patching the method setIsSelected it works.

TreeNode.prototype.setIsSelected = function (value) {
  if (this.isLeaf || !this.children) {
    this.treeModel.setSelectedNode(this, value);
  } else {
    this.treeModel.setSelectedNode(this, value);
    this.children.forEach((child) => child.setIsSelected(value));
  }
  return this;
};

But when I’m trying to check only node paths fully loaded gets selected. Any workaround for this?

UPDATE

Was able to make it work by adding this.

Object.defineProperty(TreeNode.prototype, 'isSelected', {
  get: function () {
    if (this.isLeaf || !this.children) {
      return this.treeModel.isSelected(this);
    } else {
      return some(this.children, function (node) {
        return node.isSelected;
      });
    }
  },
  enumerable: true,
  configurable: true
});

PS: Great component all and all!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
klteograsscommented, Feb 7, 2018

@omid-nazifi you assign the node id to selectLeafNodeIds

        treeModel.selectedLeafNodeIds = Object.assign({},
          treeModel.selectedLeafNodeIds, { [node.id]: true });
1reaction
omid-nazificommented, Feb 5, 2018

Thanks you @wendelstam It was a great note. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Async Data - Getting Started
The tree allows to load children asynchronously using getChildren option, and hasChildren field on the node.
Read more >
jquery selecting/unselecting checkboxes in children/parent <li>
Basically, if you check a parent, all the children are selected and when you uncheck a child, all the parents associated with it...
Read more >
Unconsistent behavior for selectedLeafNodeIds when using ...
Hello,. I am using a tree with checkboxes, triState and async loading (v8.4.0). I use state.selectedLeafNodeIds to get the checked items but ...
Read more >
useGridList – React Aria - React Spectrum Libraries
Async loading – Support for loading items asynchronously, with infinite and virtualized scrolling. Keyboard navigation – List items and focusable children ...
Read more >
Testing async stuff in React components with Jest and react ...
When data is not there yet, you may display a placeholder UI like a spinner, "Loading..." or some skeleton item. Data view. When...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found