Replies: 16 comments 7 replies
-
I am assuming you are using the standard Microsoft datagrid control. Third party controls hopefully follow all the data binding rules, but sometimes they don't. Normally, when you bind a list to a datagrid, each time the user enters a row in the datagrid, the control will call All the rules about n-level undo and how it interacts with Windows Forms is documented in the Using CSLA 3 book. The most current example of Windows Forms binding with a datagrid is the SimpleNTier sample. |
Beta Was this translation helpful? Give feedback.
-
Thank you very much! I refer to the object binding of "projecttracker". The sub object binding grid control is gridcontrol of devexpress. Modifying and adding lines are normal when the root object is saved. Occasionally, there is an error in deleting a row when the root object is saved.
|
Beta Was this translation helpful? Give feedback.
-
I added an interface "frmorder" to "project Tracker" to reproduce errors. |
Beta Was this translation helpful? Give feedback.
-
I have a WPF app using csla 5.4.0 and I have noticed that this error can be triggered if I put a breakpoint in the code and debug the app. I learned to treat this as an inconvenience because so long as I don't put breakpoint then all is fine. This doesn't happen all the time but it does happen from time to time. It seems like when a breakpoint breaks it will in some circumstances trigger this EditLevel mismatch exception and this has nothing to do with BeginEdit, ApplyEdit, and CancelEdit matching. This behavior has been going on in the earlier csla versions. |
Beta Was this translation helpful? Give feedback.
-
We have reproduced this error on a DevExpress Grid Control only when Filtering the DataSource. |
Beta Was this translation helpful? Give feedback.
-
@pszittyay if you have a solution, I'd love a PR. The trick with these sorts of issue, is that the code must work with the Microsoft datagrid. Working with third party controls is fantastic, as long as the in-the-box controls continue to work. It might be a problem with |
Beta Was this translation helpful? Give feedback.
-
Try replacing the delete code with this
|
Beta Was this translation helpful? Give feedback.
-
The most common cause of this, from years ago, was when a datagrid control didn't correctly interact with the What a datagrid control must do is always invoke Some datagrid controls didn't always call the Cancel or End edit methods, depending on how focus left the datagrid for other controls in the UI. That would leave the row on which the user was last editing in the middle of an edit, because neither Cancel nor End was invoked. |
Beta Was this translation helpful? Give feedback.
-
I stopped relying on the grid's events (At least for the Delete Operation) and instead manually call the parent object's remove function. |
Beta Was this translation helpful? Give feedback.
-
Did that get your app working? |
Beta Was this translation helpful? Give feedback.
-
O Yes. Way back in 2006-2007, I faced the same problem in CSLA 3.7 & DevExpress Grid. |
Beta Was this translation helpful? Give feedback.
-
This is always the hard part - I do (did) all my testing against the Microsoft controls, because there's no way to test against all the other random controls out there. Sometimes a workaround is all there is... @455986780 I'm not sure if @ashishsinha24 's workaround will solve your issue? |
Beta Was this translation helpful? Give feedback.
-
Let me know if this works on your end. |
Beta Was this translation helpful? Give feedback.
-
I disabled "DisableIEditableObject= true" in the business object constructor, It's running well now! |
Beta Was this translation helpful? Give feedback.
-
Our grids are based on the standard public override void ApplyFilter(PropertyDescriptor property, object filter)
{
OnFilterChanging();
base.ApplyFilter(property, filter);
OnFilterChanged();
}
public override void RemoveFilter()
{
OnFilterChanging();
base.RemoveFilter();
OnFilterChanged();
}
public event EventHandler FilterChanging;
private void OnFilterChanging()
{
if (FilterChanging != null)
FilterChanging(this, EventArgs.Empty);
}
public event EventHandler FilterChanged;
private void OnFilterChanged()
{
if (FilterChanged != null)
FilterChanged(this, EventArgs.Empty);
}
public override void ApplySort(PropertyDescriptor property, ListSortDirection direction)
{
OnSortChanging();
base.ApplySort(property, direction);
OnSortChanged();
}
public override void ApplySort(string propertyName, ListSortDirection direction)
{
OnSortChanging();
base.ApplySort(propertyName, direction);
OnSortChanged();
}
public void RefreshSort()
{
if (IsSorted)
ApplySort(SortProperty, SortDirection);
}
public override void RemoveSort()
{
OnSortChanging();
base.RemoveSort();
OnSortChanged();
}
public event EventHandler SortChanging;
private void OnSortChanging()
{
if (SortChanging != null)
SortChanging(this, EventArgs.Empty);
}
public event EventHandler SortChanged;
private void OnSortChanged()
{
if (SortChanged != null)
SortChanged(this, EventArgs.Empty);
} The Then in your UI, subscribe the appropriate events if sorting and/or filtering is supported: private void BindUI()
{
// ...
filteredBindingList.SortChanging += OnFilterOrSortChanging;
filteredBindingList.FilterChanging += OnFilterOrSortChanging;
// ...
}
private void OnFilterOrSortChanging(object sender, EventArgs e)
{
bindList.EndEdit();
} |
Beta Was this translation helpful? Give feedback.
-
I did just fix a bug with The fix is in the new v5.5.0 prerelease I just pushed to NuGet. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
Under the main object, there is a collection of sub objects, which are bound to the grid control of windows forms.
When deleting rows from the grid, click save main object.ApplyEdit () error.
"Csla.Core.UndoException:“Edit level mismatch in ".
If the code under the main object is annotated, there will be no error.
Version and Platform
CSLA version: 5.4.0
OS: Windows
Platform: WinForms
Code that Fails
if (saveObject)
{
if (business != null)
business.ApplyEdit();
Stack Trace or Exception Detail
at Csla.Core.UndoableBase.AcceptChanges(Int32 parentEditLevel)\r\n at Csla.Core.UndoableBase.Csla.Core.IUndoableObject.AcceptChanges(Int32 parentEditLevel, Boolean parentBindingEdit)\r\n at Csla.BusinessListBase
2.AcceptChanges(Int32 parentEditLevel)\r\n at Csla.BusinessListBase
2.Csla.Core.IUndoableObject.AcceptChanges(Int32 parentEditLevel, Boolean parentBindingEdit)\r\n at Csla.Core.FieldManager.FieldDataManager.Csla.Core.IUndoableObject.AcceptChanges(Int32 parentEditLevel, Boolean parentBindingEdit)\r\n at Csla.Core.UndoableBase.AcceptChanges(Int32 parentEditLevel)\r\n at Csla.Core.BusinessBase.ApplyEdit()\r\n at iPoint.iWork.Base.Win.Libary.Docenter.TableNameControl.RebindUI(Boolean saveObject, Boolean rebind) in D:\TestProject\UI\WinForms\TableNameControl.cs:line 955Additional context
Add any other context about the problem here.
Beta Was this translation helpful? Give feedback.
All reactions