Current filter:
                                You should refresh the page.

                                1 Solution

                                Creation Date Importance Sort by


                                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.

                                [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).

                                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.

                                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 all comments
                                • Andreas Mummenhoff 05.27.2015

                                  Sounds good - one more idea: why not inherit from NonPersistentObjectSpace and override "ObjectsGetting" instead of attaching this cascade of events with tedious type checking? This would also open the possibility to extend the concept with virtual OnNew/OnDelete/OnSave methods.

                                • Aleksei M. (DevExpress) 05.28.2015

                                  Hello Andreas,

                                  Thank you for your interest in the "Non-persistent Objects" feature.
                                  We will continue to develop this functionality in the future. Your ideas will be taken into account as well.

                                • Willem de Vries 05.28.2015

                                  +1 for Andreas' proposal.
                                  Does this implemented functionality imply that we can use NonPersistentObjects in the reporting module as well?

                                • Dennis (DevExpress Support) 06.01.2015

                                  @Willem: In general, this feature is implemented at the NonPersistentObjectSpace level and thus should work regardless of the data representation way. We have not specially tested it with reports, but should you have difficulties implementing the same for your reporting scenarios, please let us know in a separate ticket. Thanks.

                                • Willem de Vries 06.01.2015

                                  ok, will do.

                                • Dennis (DevExpress Support) 06.02.2015

                                  @Willem: I forgot to ask you to tell us more about the most important use-case scenarios that involve non-persistent objects and reporting. Please describe the steps and expected results from both the developer and end-user perspectives, if possible. This would be a huge help.

                                • Dennis (DevExpress Support) 06.03.2015

                                  @Willem: See the Reports - Support creating reports for a non-persistent type via CollectionDataSource ticket to learn more about solutions introduced for the most basic scenario.

                                • Willem de Vries 06.03.2015

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

                                • Dennis (DevExpress Support) 06.03.2015

                                  @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.

                                • Konstantin B (DevExpress) 06.04.2015