Field Changed Event Inside a Collection Field Handled by Outer Form

I am trying to get a change inside a collection field to trigger a change to the main form, but I am having trouble.


If I use the ValueChanged event from inside the collection field's UIModel, that works great, but then when I try to access the RootUIModel() to get to the parent form it returns null.

If I try to use the ValueChanged event on the collection field from the main form's UIModel, the event never fires. I've found that ActiveRecordChanged() fires, but this isn't specific enough, nor useful in the case when they are only working in one row.


Has anyone had success triggering events in the main form based on changes to collection field values?

Comments

  • HI Harry,


    I have not tried this There is a collectionfieldchanged event that may be handled in some forms. I haven't used it before.


    Hope this helps.


    Ernie
  • I found a solution if anyone else is interested.


    The collection field has .Value.ListChanged that fires anytime anything inside the collection field changes. This includes adding rows, removing rows, updating fields, changing properties, lots of things.


    The event args e includes e.ItemChangedType which describes what the change was.


    Casting the event args e to (CollectionFieldListChangedEventArgs)e gives an object that has the row index and a source event


    Casting that source event (UIFieldChangedEventArgs)((CollectionFieldListChangedEventArgs)e).SourceEvent gives an object that includes useful things like field name and which property changed.


    Hope this helps someone else.

Categories