panoramicdata / PanoramicData.Blazor

Blazor components
MIT License
56 stars 5 forks source link

PdTree: A parent item with key '1' could not be found #13

Open elylv opened 4 years ago

elylv commented 4 years ago

I am trying to create a treeview from a self-referential table, with a format like:

Id  Name     ParentId
1   Item1     null
2   Item2     null
3   Item1.1   1
4   Item1.2   1

However, when I try to use this data, I get an error that "A parent item with key '1' could not be found". I am debugging and intercepting the data being returned in the GetDataAsync procedure, and can confirm that each item has a matching ParentId (or null).

It looks like the parent items have to appear before any child items in the list? This is pretty awkward, especially if we are going to be rearranging items within the tree.

Is there example code of how we're supposed to bind to this type of data. The file explorer demo is cool, but a good example of binding to a self-referential table with int keys would be more useful.

elylv commented 4 years ago

Update: The code runs after sorting by ID, to ensure nothing references a parent which is later in the list, however, it only shows the parent items in the list on the page, with nothing happening when I click on them (and inspecting the HTML, it doesn't seem to be set to actually try and do anything when the nodes are clicked).

MarkGoldring commented 3 years ago

Are you loading each node as its expanded? If so please ensure LoadOnDemand is set to true. The latest library has seen some work to the PDTree component to allow greater drag and drop support. There are also now 3 demo pages for the component and the second demonstrates load on demand functionality.