Child Form N-Level Undo Problems

Child Form N-Level Undo Problems

Old forum URL: forums.lhotka.net/forums/t/3255.aspx


kbcb posted on Tuesday, July 24, 2007

Hello all... My subject is not an uncommon one, but after reading post after post, I haven't found an instance of this particular problem (yet). Here is my situation:

Provider
  Physicians : PhysicianList<PhysicianList, Physician>
  TaxId
  ...

Physician
  Credentials : CredentialList<CredentialList, Credential>
  FirstName
  LastName
  ...

Credential
  Name

My provider edit form has an editable grid of physicians. When you double-click on an item within the editable grid, it opens a physician edit form which has an editable grid of credentials. I do this because there are certain fields of the physician that I want to be editable on the provider form, and certain fields I want to be editable individually by the physician edit form.

N-Level undo works just fine for the provider, but when double-clicking on the physician grid and editing the credentials of the physician, I encounter problems (mainly when canceling).

I have managed to debug the issue down to what I believe the problem is:

After the provider form is loaded, the first physician is focused; This leaves the provider at EditLevel 1 and the focused physician at EditLevel 2. When I double-click the physician, it constructs the physician edit form which binds to the physician and the credentials. Because the EditLevel is 2 from the parent's grid (which is a bound grid, causing the _bindingEdit value to be true), the call from the binding source to begin edit does not cause the physician to raise edit levels. So, after the physician edit form is constructed, the physician is left at EditLevel 2 and the physician's credentials at EditLevel 2 as well. The problem, is that when the Show method of the physician edit form is called (I believe), the parent provider's physician grid loses focus to switch to the physician causing EndEdit to be called by the parent provider's physician grid. This causes the physician's EditLevel to be dropped back down to EditLevel 1.

The above (as described) I believe to be the main cause of the problems I am encountering. I have read allt he posts regarding calling EndEdit and CancelEdit on the binding sources (which I have done) and still find the results to be incorrect. I was originally using CSLA 2.1, and then rocky had mentioned the problem might be fixed in CSLA 3.0. So, I switched to 3.0 and still have the same problem(s). I am using the 3rd party grid control library from DevExpress, but I don't believe this is a problem with the grid library, I think this is more of a fundamental design issue, and I'm trying to figure out how to properly fix the problem.

Could someone please help enlighten me on what I should do given the above scenario? I would appreciate the help greatly - I've been beating my head against the wall on this one for a couple days straight now.

ajj3085 replied on Wednesday, July 25, 2007

kbcb:
My provider edit form has an editable grid of physicians. When you double-click on an item within the editable grid, it opens a physician edit form which has an editable grid of credentials. I do this because there are certain fields of the physician that I want to be editable on the provider form, and certain fields I want to be editable individually by the physician edit form.


That almost sounds like two different use cases to me.  One use case allows quick editing of certain properties over a group of providers, the other allows full editing of a provider.  Also, it would seem (and correct me if I'm wrong) that you would only be editing the credentials on the full edit screen.  So your grid's BO doesn't need that collection at all.

I'd create another BO to handle the full edit case.  When that form is saved, it could raise an event giving it the newly saved BO so that the BO linked to the grid can update itself.

Just my two cents.
Andy

Copyright (c) Marimer LLC