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.
Validation - Validate rules' aggregated objects if their master object is changed when ListView has MasterDetailMode = ListViewAndDetailView
Answers approved by DevExpress Support
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.
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
- v15.2.4Download Official Update
- v15.1.9Download Official Update
- v14.2.11Download Official Update
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;
}
}
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…
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.