How to use nested grids with an object represented by Csla.Blazor.ViewModel #4297
Replies: 2 comments 5 replies
-
Hi. How are you creating the object graph? The screenshot provided suggests you are getting a NRE because the application context is probably not set correctly. This has nothing to-do with the view model as far as I understand the screenshot. |
Beta Was this translation helpful? Give feedback.
-
Is it possible that the data grid control is adding a new item to the grid without going through the data portal? In such a case, the object wouldn't be initialized correctly and can't work. This is a common issue with data grid controls, as they don't follow any standard approach for creating new objects to add to the grid (and therefore the collection). |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have a root BusinessClass that has children represented by BusinessListBase classes whose items are BusinessBase child objects, which in turn have children represented in the same manner and can even have further descendants. In other words, I have relationships where the root object (Grandparent) has children (Parents), their children (Grandchildren), and their children (Great-grandchildren).
In my Blazor application, I define a class Csla.Blazor.ViewModel viewModel that I load from the database with all its childs in the OnAfterRenderAsync event of the Blazor page.
To display the data of the children, grandchildren, and great-grandchildren in the UI, in the Blazor page, I want to use nested grids or components by level, but I don't know how to assign a list that is a property of the Csla.Blazor.ViewModel because if I directly assign a BusinessListBase, it generates NullReferenceException errors in the CSLA properties of the class, as shown in the example:
If I use the ReadOnly versions of the objects where the Grandparent is a ReadOnlyBase root that has a property ReadOnlyListBase for the list of Parent ReadOnlyBase children, everything works, and when moving between grids, the data is updated.
The problem is with the classes that allow editing, and the solution I have been using so far involves versions of the DTO objects of the classes where I add properties to manage editing such as IsDirty, IsNew, IsDeleted, etc., but obviously, that is not the idea; it is complex to synchronize the DTO with the editable objects to make updates to the database, and the goal is to be able to use all the properties of CSLA.
How can I pass a BusinessListBase to the grid or as a parameter to a Blazor component?
How do I load a Csla.Blazor.ViewModel with the BusinessListBase object?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions