Clarifying expected behaviour when editing related data in a grid


Author
Message
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yep, that would work, too.  I think the SetEditingState() was changed from Friend (internal) to public recently, and it might not be in the latest release, so calling Edit() would work just as well.
thegwill
thegwill
StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)
Group: Forum Members
Posts: 16, Visits: 177
...and there's no .SetEditingState() method and the .EditingState property is read only

How about I call .Edit() with the same effect:

if (childBO.IsDirty && parentBO.EditingState == BusinessEditingState.Idle)
    parentBO.Edit();

thegwill
thegwill
StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)
Group: Forum Members
Posts: 16, Visits: 177
Thanks Ben

Just to be clear: your example code is handling the event on an instance named "bo" and is also setting the edit state on the same instance - I thought that I would need to handle the event on "childBO" and set the edit state on "parentBO" or am I misunderstanding the purpose of the dirtyness?

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Also, for clarification: assuming I can get this working, what would the Undo button do to the child records? Would it undo all changes if I had changed multiple child record values in the grid or just the last row changed? I'm hoping the former...

It is the former, by default.  However, you will need to change the IncludeInFormUndo property on the form to AllBusinessObjects.  By default, it's only PrimaryBusinessObject, which means that a call to Undo() on the form will only undo the changes to the primary business object.

As for the state of the buttons, there is a new event on the business objects, introduced in 1.6.1, called IsDirtyChanged.  You'll want to handle that event and set the editing state of the business object.  The editing state does not get changed internally unless you manually call the Add() or Edit() methods.  So, something like this will change the state of the toolbar buttons:

Private Sub bo_IsDirtyChanged(ByVal sender As Object, ByVal e As EventArgs) Handles bo.IsDirtyChanged
    If bo.IsDirty Then
        bo.SetEditingState(BusinessEditingState.Editing)
    Else
        bo.SetEditingState(BusinessEditingState.Idle)
    End If
End Sub

thegwill
thegwill
StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)
Group: Forum Members
Posts: 16, Visits: 177
I have a maintenance form to modify a business object. The form also has a grid containing related child data which is wired up using binding etc.

All seems to work as expected apart from when editing values in the grid (the "child" records) the form's tool strip does not go into "edit mode". How can I get the MFTS to react to the child records in the grid / BO?

Also, for clarification: assuming I can get this working, what would the Undo button do to the child records? Would it undo all changes if I had changed multiple child record values in the grid or just the last row changed? I'm hoping the former...

Thanks in advance

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search