doc words with
doc words like
Rows in the same table with child/parent relationship?
Forgive my ignorance on the subject, but I've run into another issue...
So, I have an "items" table, which describes an item (manufacturer, part number, etc). I also have an "inventory" table which describes instances of those items, and their attributes (vendor, serial number).
Now, in some cases, I might assemble some number of parts together. So, maybe I have an "item" described as "assembly", where I am the manufacturer.
I would like to create an instance of inventory referencing this "assembly" item, and then allow a row of inventory to be a child of another row of inventory.
I have been able to get some of this working. My inventory table successfully references itself and I can navigate this reference, however I have not figured out how to "select" the parent inventory row. Or, from the parent, search, then assign some number of resultant rows as "children".
Nice to hear from you.
I suppose you have looked to the Tree example. I suppose you have a fieldPropery named "parentId" that is mapped to a column in your table, that for each Inventory row holds the id of its parent row? And a derived property "parent" that allows you to navigate to the parent? And a multi value property "children" to navigate to the children (you did set its twinName to "parent").
Then the default user interface should allow you to:
1. Show an index page with all Inventory objects (initially empty),
2. from there create a root Inventory object and save it. It is a root inventory object because it has no parent,
3. show the list of children (empty)
4. create a child Inventory object that will automatically reference the parent Inventory object through its "parent" propery and save it,
5. From the index page create a second root inventory object,
6. From the first root inventory object, select the second root inventory object as its parent, then save. This will make your first root inventory object to be the child of your second root inventory object. Therefore it is no longer a root object, the "second" root object has become the only root object.
Does this make sense to you?
Add a Reply
Loading form, please wait
The website will not send you an e-mail when a reply is added to this topic
Back to Topics List