Child items in Blazor Grid #3220
-
I am utterly confused about the usage of child items now. I don't understand why an item in a list is automatically considered a child when the item is used in a grid. I understand the child concept when it comes to parent child relationships such as purchase order and purchase order line items---there a child makes a lot of sense. But insofar as needing to create a child for display purposes is causing a lot of problems. I can't add a non-child object to a list for display purposes, and then I can't save an individual item from the list because it's a child. Children to me take on some type of attribute from the parent. OMHO just because an item is viewed in a list doesn't mean it should be considered a child. Going back to the Parent Child relationship, if I want to add the list of Purchase orders parents to a list, now they have to be identified as children--all for display purposes. Now I'm wondering if this is a problem because I'm using automapper to map items in an object factory. I have to identify in the class's default constructor that an object is a child. This allows me to use automapper to map the graph. If I don't identify in the default constructor that the class is a child, the object map graph goes nuclear. However, this also sets up the problem of wanting to list purchase orders for a department in a grid. I can't add the purchase order to the list because it's not a child. So now I'm left with creating additional classes. This becomes very clear with another example: Code/lookup tables. To view the items in a list each class needs the child attribute (like US States), but another class is needed because during save, it's not a child. Then there is another class with a from ReadonlyBusinessBase that is identified as a child because the items are used in a listbox. Is this where I'm at, 3 classes for each table in the database? Can someone please tell me how to get out of this vicious circle? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
There's an alternate grid type (DynamicListBase) that is a container for root objects, so you don't need to use a list type that contains child objects.
|
Beta Was this translation helpful? Give feedback.
-
Now I'm excited to check this out. OMG!!!!! You absolutely rock, Rocky. |
Beta Was this translation helpful? Give feedback.
-
I have made a number of objects 'switchable' i.e., those objects could be used both as child and root (depending upon the UI). |
Beta Was this translation helpful? Give feedback.
There's an alternate grid type (DynamicListBase) that is a container for root objects, so you don't need to use a list type that contains child objects.
BusinessListBase
contains child objects, and those child objects are retrieved and saved by the root object, which is often that collection.DynamicListBase
contains root objects, and those root objects are independently retrieved and saved based on the use of the standard data binding interfaces (mostlyIEditableObject
). It was originally designed to support per-row editing in Windows Forms datagrid controls, whereIEditableObject
is used. In current UI frameworks I've noticed that not all datagrid controls use this interface, which ofte…