Ticket Q458979
Visible to All Users

Validation - Validate rules' aggregated objects if their master object is changed when ListView has MasterDetailMode = ListViewAndDetailView

created 12 years ago

If an object is modified in ListViewAndDetailView'-mode, validation rules of aggregated child objects are not evaluated. If the same object is opened and edited in a detailview, validation for child objects works as expected.
I attached a screencast and a simple demo project showing this behavior for an object 'BO1' and an aggregated child 'BO2' with a rule that ́s always false.

Comments (1)
DevExpress Support Team 12 years ago

    Thank you for your report. I see the issue. We need some time to research it. I will get back when an answer is found.

    Answers approved by DevExpress Support

    created 9 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:

    Hello Hurzi!,

    Thanks for your feedback. We have improved this scenario in the next minor updates so that no extra settings or custom code are required. Previously, we also improved a similar scenario in the context of this thread: Validation - Aggregated property validation can be bypassed when this single property is edited in the embedded DetailView of the ListView with MasterDetailMode = ListViewAndDetailView. I hope you will find this helpful for your business as well.

    Regards,
    Dennis

      created 12 years ago (modified 12 years ago)

      Thank you for contacting us.
      I have investigated your solution and found that this behavior is implemented by the PersistenceValidationController class. This class doesn't check validation rules for aggregated objects when it works in a ListView: "In the Save validation contexts, only modified objects are validated, if the Controller has been activated for a List View." This behavior is by design to avoid performance issues.
      Nevertheless, you can manually add necessary objects to check validation rules using the PersistenceValidationController.CustomGetAggregatedObjectsToValidate event:

      C#
      public class MyController : ViewController<DetailView> { PersistenceValidationController pController; protected override void OnActivated() { base.OnActivated(); pController = Frame.GetController<PersistenceValidationController>(); if (pController != null) { pController.CustomGetAggregatedObjectsToValidate += CustomGetAggregatedObjectsToValidate; } } void CustomGetAggregatedObjectsToValidate(object sender, CustomGetAggregatedObjectsToValidateEventArgs e) { Contact ownerObject = args.OwnerObject as Contact; if (ownerObject != null) { if (ownerObject.Address != null) args.AggregatedObjects.Add(ownerObject.Address); args.Handled = true; } }

      See also Validation - Rules for aggregated child objects are checked when saving a master object in a Detail View.

        Show previous comments (2)
        DevExpress Support Team 12 years ago

          Thank you for the update. The PersistenceValidationController class is designed to work at the 'root' level only: there should be one active instance of this class for a created IObjectSpace object. This class is not designed to work in the nested DetailView or ListView because in this case there will be several active PersistenceValidationController objects and each object will show a validation result dialog. This is why we cannot apply this solution and suggest that you use the PersistenceValidationController.CustomGetAggregatedObjectsToValidate event.

            I just want to note for others that the controller above won't work properly if you work in 'ListViewAndDetailView' mode. The problem is that CustomGetAggregatedObjectsToValidate never gets triggered as long as the controller targets only DetailViews. Therefore I had to derive just from ViewController and not ViewController<DetailView> for CustomGetAggregatedObjectsToValidate method to be called when saving a DetailView in ListViewAndDetailView-mode.

              Any news from DevExpress?
              With the ModelEditor it is easy to change a ListView to 'ListViewAndDetailView'. This flexibility is really great. But if a simple GUI change will break validation/business rules, it is quite useless. I think we need a out-of-the-box solution…

              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.