minop1205 / react-dnd-treeview

A draggable / droppable React-based treeview component. You can use render props to create each node freely.
MIT License
530 stars 71 forks source link

不具合報告:InitialOpen Error #136

Closed OldManMeta closed 2 years ago

OldManMeta commented 2 years ago

The InitialOpen={true} appears to only target droppable folders so to speak.

I have a scenario where some folder can take certain files but not others, so being able to ensure all folders, and not just droppable=true was expanded would provide a wider experience.

Perhaps allow an object to specify the InitialOpen target instead of just a bool?

Cheers

OldManMeta commented 2 years ago

Ok - I just noticed that you can pass an array of id's in - so I wrote this function to get them

`const getFolderItems = (treeData:NodeModel[]):[]=>{ var TreeFolders:[]=[];

treeData.map((item)=>{
  if(item.isFolder){
    TreeFolders.push(item.id);
  }

});

return TreeFolders;    

}`

Obviously, calling it with: initialOpen={getFolderItems(treeData)}

You will need to modify the data and structures to contain a value of isFolder:boolean