Ticket S19068
Visible to All Users

Core - Provide an easy way to show a list of non-persistent objects created at runtime

created 17 years ago

See also:
- "How to pass PropertyCollectionSource as CollectionSource for PopupWindowShowAction" at http://www.devexpress.com/issue=CQ38893
- "How to display a list of non-persistent objects while retaining the possibility to 'add' new objects" at http://www.devexpress.com/issue=Q34001
- Core - Improve usability and support more scenarios of working with non-persistent objects
See Also:
WorldCreator module of eXpand
Creates dynamic persistent assemblies. The XAF user interface allows us to create an assembly without writing a single line of code. Advanced users can even use c# scripting and create new code generation templates.
Thanks,
Dan

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

We have implemented the functionality described in this ticket. It will be included in our next update(s).

Please check back and leave a comment to this response to let us know whether or not this solution addresses your concerns.

Additional information:

Now you can open a non-persistent object's List View from the Navigation using the following approach.

Declare a non-persistent class and decorate it with the DomainComponent and DefaultClassOptions attributes.

C#
[DomainComponent, DefaultClassOptions] public class MyNonPersistentObject { // ... }

Edit the WinApplication.cs/WebApplication code. In the overridden CreateDefaultObjectSpaceProvider method, register an extra Object Space Provider of the NonPersistentObjectSpaceProvider type (in addition to the existing XPObjectSpaceProvider or EFObjectSpaceProvider).

C#
protected override void CreateDefaultObjectSpaceProvider(CreateCustomObjectSpaceProviderEventArgs args) { // ... args.ObjectSpaceProviders.Add(new NonPersistentObjectSpaceProvider(TypesInfo, null)); }

If you run the application now, you will see that the My Non Persistent Object  navigation item is created. It opens the List View which is empty, but you can create non-persistent objects with the New Action. If you reopen the List View, all created objects will, obviously, disappear.

You can fill the List View programmatically. Edit the Module.cs file located in the module project. In the overridden Setup method subscribe to the XafApplication.ListViewCreating event. In the event handler, if the Collection Source's object type is MyNonPersistentObject, subscribe to the NonPersistentObjectSpace.ObjectsGetting event
 and populate the e.Objects collection as required.

C#
public sealed partial class MySolutionModule : ModuleBase { // ... public override void Setup(XafApplication application) { base.Setup(application); application.ListViewCreating += application_ListViewCreating; } void application_ListViewCreating(object sender, ListViewCreatingEventArgs e) {         if (e.CollectionSource.ObjectTypeInfo.Type == typeof(MyNonPersistentObject)) {             ((NonPersistentObjectSpace)e.ObjectSpace).ObjectsGetting += objectSpace_ObjectsGetting;         }     } void objectSpace_ObjectsGetting(object sender, ObjectsGettingEventArgs e) { if (e.ObjectType == typeof(MyNonPersistentObject)) { BindingList<MyNonPersistentObject> objects = new BindingList<MyNonPersistentObject>(); for (int i = 1; i < 10; i++) { objects.Add(new MyNonPersistentObject() { Name = string.Format("Object {0}", i) }); } } e.Objects = objects; e.Handled = true; } }

The result is demonstrated in the image below:

See also:  How to: Display a Non-Persistent Object's List View from the Navigation

    Show previous comments (7)

      Thanks Dennis, for answering your own question :).
      I think the reffered ticket shows promising features. Thank you!
      Willem

      Dennis Garavsky (DevExpress) 10 years ago

        @Willem: My new ticket just describes the most basic scenario that came to mind. So, I requested the information about concrete use-cases you and your clients were interested in to consider it for the future as well. If this basic scenario covers your needs, then there is no need to answer.

        DevExpress Support Team 10 years ago

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.