Wiki Home

Vfe Filtered Grand Child

Namespace: WIN_COM_API
Notes on how to set up a Parent, Child, GrandChild that can be edited as one entity.

If you're talking about having a cursor of all grandchildren filtered as you navigate between children, consider using SET KEY. You'd need an index on the grandchild table INDEX ON child+ fields from the grandchild table. Then just SET KEY TO childid,childid in grandchild. -- Mike Yearwood
Basically, the filter needs to be set anytime the record pointer is changed in the child. I created a method of the child presobj - the code is below. I call this from just a couple of places, I think. Using good ole Code References I see I'm calling it in these places...

A call to RefreshUI() is needed after the filter is set.

Child PresObj's Save_post() - my comments say I put it here because there is record pointer movement on a save.

Child Grid's OnRowChange_post() - See the old thread you referred to where I think Mike explains why. # In addition to OnRowChange_Post() the filter needs to be set any time the form's Navigate() is called

Form's DoChildForm() - because I found the grandchild grid needed to be refreshed after the edit form was closed.

Parent Child PresObj's Save_post() - my comments say I had to do this to deal with a grid highlighting anomoly. Some framework bugs possibly related to this have been fixed along the way, so perhaps this is no longer an issue.

  1. The filter needs to be set right after form instantiation. I'm actually doing this on the form's first Activate().
  2. When returning from the edit form for the child, the filter will need to be set (that is if you have navigation buttons on the edit form). Interesting VFP tidbit here, you need to check PCOUNT() to determine how many parameters to pass to DODEFAULT() within the form's DoChildForm() method. This is because the code in the superclass runs code conditional to PCOUNT, and PCOUNT returns based on the number of commas plus 1 (See Hack Fox entry for PCOUNT). You will get errors if you blindly pass all the parameters to the superclass in the dodefault() call.
( Topic last updated: 2004.06.05 12:30:10 PM )