Read Only Base With Editiable Children

Read Only Base With Editiable Children

Old forum URL: forums.lhotka.net/forums/t/11572.aspx


mehgerbil posted on Tuesday, September 11, 2012

I don't know if this is possible (or recommended) but I wanted to get your thoughts on how I should put this object series together.    I've a list of records that will be displayed on the left hand side of the screen in a datagrid and as you move through the grid the details of each record will show on the right hand side of the screen.

If this were entirely read only it wouldn't be an issue; however, I'd like the user to be able to add 'Notes' to each record which suggests that each record, although read only, has a collection that is editable - or more precisely, the user can add notes but not edit or delete.

So can I have a read only base class have a collection of editable objects?

Thoughts?

JonnyBee replied on Tuesday, September 11, 2012

You can have a "root" editable list as a property on a readonly object.

You must however be aware that you must call save on the "root" editable list and update the readonly object with the newly saved object.

In order to avoid loading to much data I'd prefer to decouple the strucctures.

IE:

  1. a list of readonly objects
  2. a "root" editabllye list that is loaded per the selected readonly object.

thaehn replied on Tuesday, September 11, 2012

I have done the same thing.  I used a command object to save the notes.  I put up a child window with and "OK" and "Cancel" buttons.  After hitting "OK" I created the command to save the data.

mehgerbil replied on Tuesday, September 11, 2012

Both of you, thanks for the thoughts.   I was hoping that those options were a good fit.

 

Copyright (c) Marimer LLC