Suppose that it is necessary to provide a capability to work with documents. These documents can have various sets of fields, in various orders. To implement this scenario using standard XAF tools, it is necessary to create a lot of business classes, one for each kind of document. This solution doesn't allow the creation of a new document kind.
This example solves the described above task in the following way:
There is a Document class, which contains fields, common for all documents. It has an associated collection of document items, represented by the DocumentItemBase class and its descendants. To place document items into the Document DetailView, a custom property editor named DocumentItemsPropertyEditor is implemented. It is used for the Document.Items collection and draws a table with editors associated with document items. As a result, it is possible to customize editors shown in the DetailView at runtime.
Note that the example uses the InMemoryDataStoreProvider. To use another database, you need to modify the Session_Start event handler from the Global.asax.cs file.
See Also:
Implement Custom Property Editors
Question Comments
Added By: vguruv at: 7/5/2012 6:56:25 AM
Does not work in edit mode on v12.1.4
Added By: Louis Z at: 5/26/2014 7:12:10 AMThis example fails on 'New'. Run, click new button.
NullReferenceExeption: Object reference not set to an instance of an object.
private void CreateLayoutItems(LayoutControl layout) {
....
for (int i = 0; i < itemsPerRow - columnIndex; i++) {
FAIL --> row.Add(new EmptySpaceItem());
}