Ticket Q371273
Visible to All Users

Sorting does not work stably when committing a nested ListView on every current object change

created 12 years ago

Hi Dennis,

we discovered a problem with the sorting in nestedListViews with activated AutoCommit (AutoCommit is implemented by us on every currentObjectChanged event). The sorting works only every 2nd commit. Please have a look at the attached soluation and the video.

Thank you

Christian

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hello Christian,
I think that it would be best if you grabbed the example code from the standard XAF controller:

C#
public class ListViewAutoCommitController2 : ViewController { private void ObjectSpace_ObjectEndEdit(Object sender, ObjectManipulatingEventArgs e) { // B37305 if (ObjectSpace.ModifiedObjects.Contains(e.Object)) { // B33747 CommitChanges(); } } private void ListView_Closing(object sender, EventArgs e) { CommitChanges(); } private void ListView_QueryCanChangeCurrentObject(object sender, CancelEventArgs e) { CommitChanges(); } private void ListView_ValidateObject(object sender, ValidateObjectEventArgs e) { // B32035 CommitChanges(); } protected virtual void CommitChanges() { // B33150 if (!ObjectSpace.IsDeleting && (ObjectSpace.ModifiedObjects.Count > 0)) { ObjectSpace.CommitChanges(); } } protected override void OnActivated() { base.OnActivated(); ObjectSpace.ObjectEndEdit += new EventHandler<ObjectManipulatingEventArgs>(ObjectSpace_ObjectEndEdit); ListView listView = (ListView)View; listView.Closing += new EventHandler(ListView_Closing); listView.QueryCanChangeCurrentObject += new EventHandler<CancelEventArgs>(ListView_QueryCanChangeCurrentObject); listView.ValidateObject += new EventHandler<ValidateObjectEventArgs>(ListView_ValidateObject); } protected override void OnDeactivated() { base.OnDeactivated(); ObjectSpace.ObjectEndEdit -= new EventHandler<ObjectManipulatingEventArgs>(ObjectSpace_ObjectEndEdit); ListView listView = (ListView)View; listView.Closing -= new EventHandler(ListView_Closing); listView.QueryCanChangeCurrentObject -= new EventHandler<CancelEventArgs>(ListView_QueryCanChangeCurrentObject); listView.ValidateObject -= new EventHandler<ValidateObjectEventArgs>(ListView_ValidateObject); } protected virtual void InitializeComponent() { } public ListViewAutoCommitController2() : base() { InitializeComponent(); TargetViewNesting = Nesting.Nested; TypeOfView = typeof(ListView); } }

I have just changed its TargetViewNesting property. Unless I missed something, it all worked fine in your scenario.

    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.