Parent - child and SF ListView controls


Author
Message
Bruce Palmer
Bruce Palmer
StrataFrame Beginner (20 reputation)StrataFrame Beginner (20 reputation)StrataFrame Beginner (20 reputation)StrataFrame Beginner (20 reputation)StrataFrame Beginner (20 reputation)StrataFrame Beginner (20 reputation)StrataFrame Beginner (20 reputation)StrataFrame Beginner (20 reputation)StrataFrame Beginner (20 reputation)
Group: Forum Members
Posts: 18, Visits: 33
Hi guys. I'm currently evaluating StrataFrame. So far I'm quite impressed, though I'm still scrambling up the learning curve.Smile



If my understanding is correct, SF ListView controls each have an internal business object that is created upon creation of the control, and is of a type as specified by the PopulationDataSourceSettings property (assuming this property isn't blank).



I want to use two ListView controls on a form, lvParent for ParentBO and lvChild for ChildBO. I can't find a way to access the internal business objects of the ListView controls, so I cannot set the ParentBusinessObject property of the internal business object of lvChild to the internal business object of lvParent. This means that I can't use a relationship that has been defined in the ChildBO classes ParentRelationship property.



To get around this I drop a ParentBO and ChildBO on the form, set ChildBO.ParentBusinessObject to the ParentBO instance, set ParentBO.ChildAutoFilterOption to MatchCurrentRow, and then define the following event handlers.



private void parentBO_ParentFormLoading()

{

// Get all parent objects for the specified month.

parentBO.FillByDate(new DateTime(2006, 7, 1));

}



private void childBO_ParentFormLoading()

{

childBO.FillByParent();

}



private void lvParent_ListPopulating(MicroFour.StrataFrame.UI.ListPopulatingEventArgs e)

{

e.Parameters[0].Value = parentBO;

e.Parameters[1].Value = BusinessCloneDataType.ClearAndFillFromCompleteTable;

}





private void lvParent_SelectedIndexChanged(object sender, EventArgs e)

{

if ( (lvParent.SelectedItems.Count > 0) && (lvParent.SelectedItems[0].Tag != null) )

{

parentBO.Navigate(BusinessNavigationDirection.Absolute, lvParent.SelectedItems[0].Index);

lvChild.Requery();

}

else

{

lvChild.Items.Clear();

}

}



private void lvChild_ListPopulating(MicroFour.StrataFrame.UI.ListPopulatingEventArgs e)

{

e.Parameters[0].Value = childBO;

e.Parameters[1].Value = BusinessCloneDataType.ClearAndFillFromDefaultView;

}



Now this works fine. But, as the business objects internal to the ListView controls have copies of the data in the business objects on the form, if the business objects are large in size and/or number then there is inefficient use of memory.



An alternative method would be to delete the business objects on the form and the above event handlers, and use the following event handlers instead.



private void lvParent_ListPopulating(MicroFour.StrataFrame.UI.ListPopulatingEventArgs e)

{

// Get all parent objects for the specified month.

e.Parameters[0].Value = new DateTime(2006, 7, 1);

}



private void lvParent_SelectedIndexChanged(object sender, EventArgs e)

{

if ( (lvParent.SelectedItems.Count > 0) && (lvParent.SelectedItems[0].Tag != null) )

{

lvChild.Requery(lvParent.SelectedItems[0].Tag);

}

else

{

lvChild.Items.Clear();

}

}



This method uses memory efficiently, particularly as only chlid objects for the current parent object are in memory. The down side, of course, is that every time the parent object is changed a trip to the database is required to get the new child objects. The first method avoided this because it retrieved all the child objects in one go and was filtered as required.



Method 1 seems preferrable to me as it utilises the defined relationship in the business objects and reduces trips to the database. However I think it would be even better if I was able to link the internal business objects of the ListView controls using ParentBusinessObject. This would eliminate duplicate business objects and their contents. Is this possible or not? Have I missed something?



Thanks in advance,

Bruce



P.S. Pardon my ignorance, but how the heck to I properly format source snippets in a posting?!?

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