Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom required properties for id, parent, text etc #201

Open
elmcapp opened this issue May 3, 2023 · 0 comments
Open

Allow custom required properties for id, parent, text etc #201

elmcapp opened this issue May 3, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@elmcapp
Copy link

elmcapp commented May 3, 2023

I would be nice if we could select our own property names for the required properties.

Reason. I get my data from a api and instead of needing to map the data to match what the tree view require it would be nice if I can just use the data

Here are the required fields:

[
  {
    "id": 1,
    "parent": 0,
    "droppable": true,
    "text": "Folder 1"
  },

I would like the options to make id called UUID, I would like the option to have text called label. Check out example below

<Tree
  parentName={"parent"}
  text={"lable"}
  id={"UUID"}
  tree={treeData}
  rootId={0}
  onDrop={handleDrop}
  render={(node, { depth, isOpen, onToggle }) => (
    <div style={{ marginLeft: depth * 10 }}>
      {node.droppable && (
        <span onClick={onToggle}>{isOpen ? "[-]" : "[+]"}</span>
      )}
      {node.text}
    </div>
  )}
/>;

@elmcapp elmcapp added the enhancement New feature or request label May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants