Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to display detail collections with descendants filtered by an object type

$
0
0

Suppose we have the same classes structure as shown in the How to: Use UpCasting help topic.
Our goal is to provide two details collections into a DetailView that will allow end-users to view objects of the LocalEmployee and ForeignEmployee classes separately in a Department DetailView.
In order to do this, we will declare two calculated details collections in the Department class and also write some code to update these collections when objects are added in or deleted from the main (associated) Employees collections.
By design the Employees collection is intended to list both local and foreign employees and also to allow end-users to perform any operations with them. The LocalEmployees and ForeignEmployees collections are intended to view objects only. So, the corresponding nested ListViews will be readonly.

See Also:
How to: Set Relationships Between Objects
How to: Calculate a Property Value Based on Values from a Detail Collection
How to filter persistent objects against their type
Collection properties and the New/Delete/Link/Unlink Actions

Question Comments

Added By: Willem de Vries at: 9/12/2012 11:36:40 AM    

I'm curious why HintCollection is used despite the documentation stating:
HintCollection - This member supports the .NET Framework infrastructure and cannot be used directly from your code.

Added By: Dennis (DevExpress Support) at: 3/11/2013 2:08:29 AM    

The HintCollection property is used here to specify a data source for an XPCollection.

Added By: Randy Jean at: 12/5/2014 11:07:54 AM    

Is there any way for these descendant collections to not be read-only?  Or, at the very least, when the list view is clicked the detailview is not read-only?  

Also, on the top-level listview (not filtered) can the New button be set to always drop down the list of objects?  Users are complaining that they hit the "button" part of the New and they don't realize there are different objects to choose to add.

Added By: Dennis (DevExpress Support) at: 12/8/2014 4:48:01 AM    >>Is there any way for these descendant collections to not be read-only?  Or, at the very least, when the list view is clicked the detailview is not read-only?  

You can try to remove the following attribute from these auxiliary collections, though I have not tested this particular configuration when creating this example solution:

[ModelDefault("AllowEdit", "False")]

 In general, it is better to use separate Views for editing these collections; e.g., show an editable ListView via a command on the toolbar.



>>Also, on the top-level listview (not filtered) can the New button be set to always drop down the list of objects?
Yes, set the IModelAction.ShowItemsOnClick Property for the New Action via the Model Editor.Added By: Wojciech at: 9/8/2017 1:30:17 AM    I try to make editable descendant collections, change attribute [ModelDefault("AllowEdit", "True")]. The new button is visible but records are not stored after add.
When adding records from common listview, the descendant collections not refresh.
How to fix it ?
Added By: Michael (DevExpress Support) at: 9/8/2017 8:18:56 AM    

@Wojciech: We intentionally disabled these operations because the built-in New, Link and Unlink actions are not designed to work with collections that do not participate in relationships.

>>>The new button is visible but records are not stored after add.

In fact, the New action in the LocalEmployees and ForeignEmployees tabs creates objects, but it doesn't link them with the parent. You can create a controller for the nested list view that will subscribe to the NewObjectViewController.ObjectCreated event to initialize the new object, and then to the IObjectSpace.Committed event of the new object's detail view to add it to the collection.

>>>When adding records from common listview, the descendant collections not refresh.

You can subscribe to the XPCollection.CollectionChanged event to update filtered collections as required.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>