StrataFrame Forum

Parent-Son-Garndson Listview

http://forum.strataframe.net/Topic23097.aspx

By Ger Cannoll - 5/13/2009

I have a Parent,Son,Grandson which I am trying to display. The Parent is on a Miantemence Form and works fine. I have the Son and Grandson in two ListvIews , side by side. The Son is dispaying fine. When I land on each record of the Son, I want the Grandson records to show, just for the relevant son. Nothing is being displayed on the Grandson list. I have set up as follows: The Foreign  Key for the Grandson is got from the Primary Key on the Son

SonBo.Navigated... This.ListView2.Requery();    //to requery the Grandson ListView

Grandson.ListView.Populating...  e.Parameters[0].value  = this.SonBO["Son_PK"];  //to get Primary key from the Son

Grandson ListView.Properties... PopulateOnFormLoad=Manual  MethodToExecute=FillByParentPrimaryKey(Int32)  (primary key is Numeric)

What am I missing ?

By Trent L. Taylor - 5/14/2009

Well, with the infomration you have provided it is hard to tell what your code may be doing.  I see that you are calling the Fill method on the integer PK, but do you have the relationship setup on the BOs, etc.?  Here are some things to check:

  • Verify that the relationship is setup between the Child -> GrandChild
  • Make sure that the Navigated event of the Child is on the correct record when the Requery is called for the grandchild.
  • Make sure that you actually have records for the grandchild (I have done that before Smile)
By Ger Cannoll - 5/14/2009

Hi Trent

Verify that the relationship is setup between the Child -> GrandChild ........ Yes That is set up on the GrandChild BO

Make sure that the Navigated event of the Child is on the correct record when the Requery is called for the grandchild............The child records are displaying in List 1. I am expecting ,as I arrow down through this list, that the Grandchildren will appear automatically  in List 2 (The Grandchild) ..... is there something else here perhaps I need to call ??

Make sure that you actually have records for the grandchild (I have done that before ).... Yes I have double checked that

I just have about 25 records on each table  as a test so I can see whats happening a bit clearly

By Edhy Rijo - 5/14/2009

Hi Gerard,

Make sure the instance of GrandsonBO.ParentBusinessObject in your form has the value of the SunBO.
By Ger Cannoll - 5/14/2009

Hi Edhy,

Just checked that , and the Instance of the GrandChild BO does have the parentBisinessObject set to the Son

(By the way . in you last post , you had two lines, not separated by a Blank Line... how do you do that..all my lines have a blank line in between)

By Edhy Rijo - 5/14/2009

Gerard O Carroll (05/14/2009)
...Just checked that , and the Instance of the GrandChild BO does have the parentBisinessObjectset to the Son


Then you will either need to post a sample using the StrataFrame Sample database or start debugging the listview.populating method to see if you are getting the right Parent PK value.



(By the way . in you last post , you had two lines, not separated by a Blank Line... how do you do that..all my lines have a blank line in between)


Sure I use the "CodeSnippet" IFCode shortcuts (from the left of your browser)
By Ger Cannoll - 5/14/2009

Hi Edhy.

I will go back over the app with a fine tooth comb..just thought that mabe I was missing ... some piece of code somewhere..if I still have issues, i'll do up a smple on SF database and post it

By Ger Cannoll - 5/16/2009

Have gone back over the app...cannot see where I am going wrong. So I have set up another SamplE App using StRata Frame sample Sql Server Database....am still having the same problem trying to see the grandchildren....I know this must be something very simple that I cannot just see.. I am uploading two projects

SF_Samppl_App which has just 1 form (frmCust) (KEK_1.ZIP)

SF_SAMPLE_BO which is a BO Library with Cust,Orders and Order Lines BO set up. (KEK_2.ZIP)

I'd really apprEciate it if someone could have a look

By Edhy Rijo - 5/16/2009

Hi Gerard,



Sorry I don't have time now to explain in detail, but I changed the logic of your sample (see attached projects). Look at the listviews population method and at the BOs Navigated events.



Your BO relation definitions are OK. You will see data from record 2.



Have a nice weekend! Tongue
By Ger Cannoll - 5/17/2009

Hi Edhy, many thanks for taking the time to unzip the app and having a look at it.

I have downloaded your zip, unzipped it and it runs fine.

I'll need some time to have a look at it in detail

I see you are using a BusinessCloneDataType.. not sure what that does but I'll have a closer look and see if I can sort out my own app with the help of your download.

Many thanks again for taking the time to look at this. I am just at that learning point on the curve where I reckon if I can get some concrete results on the next few weeks I will have made a lot of progress

By Edhy Rijo - 5/17/2009

Gerard O Carroll (05/17/2009)
... I am just at that learning point on the curve where I reckon if I can get some concrete results on the next few weeks I will have made a lot of progress




Don't worry, you will do just fine, we all have been in the same spot sometime.



The listview is my favorite control, it has been enhanced to do many thing automatically. Read the Listview topic in the "UI Layer -> Controls -> ListView" help file.



I have some free time now, so here is a quick description of how to populate it: The ListView and the ComboBox uses the same type of population, they both have an internal BO to host their items. When you use the Population Type Editor, you can select any method to be executed to fill the internal BO or you can use the BO.CopyDataFrom() method which requires you to have a BO dropped on the form to fill the internal ListView/ComboBox BO, this is the way I prefer to setup ListView since usually you may want to do something else with the data in the ListView and it is easier to manipulate the data in a BO dropped in the form.



Using the BO.CopyDataFrom(BusinessLayerBase, BusinessCloneDataType) method, requires 2 parameters. In the ListView.ListPopulating event you have to assign the values for those 2 parameters, I use VB.NET, but in you case it will look like this:



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

{

e.Parameters[0].Value = this.oR_BO1;

e.Parameters[1].Value = MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromDefaultView;

}



This way, when you call the ListView.Requery() it will copy the data from the BO assigned in Parameters[0] with the required BusinessCloseDataType that you use, in most cases "ClearAndFillFromDefaultView".



Also pay attention to the "StrataFrame: User Interface Automation" properties you can use, in your case for the "Transactions" listview I used the "BusinessObject" and the "AutoNavigateToSelectedRecord" properties, this will have the effect that when you select any record in the ListView it will move the record pointer in the BO "oR_BO1" and trigger the oR_BO1.Navigated() event which will then requery the "Transactions Details" listview which has been in the same way as the "Transaction" listview.



Hope this give you and others a clear view of how the ListView/ComboBox population works. Check the references in the help file and also take a look at the StrataFlix sample which make use of the ListView and ComboBox in its own way. Also keep in mind that this is just one way to populate these controls, SF provide us with a great flexibility on how to populate these controls which you will find out once you get more familiar with the framework.
By Trent L. Taylor - 5/18/2009

Edhy, thanks for your detailed explanations and help.  I know that Gerard as well as other developers that may run into this into the future will greatly appreciate your efforts!

Gerard, hang in there.  You are making progress each week.  Before long this will all be second-hand! Wink

By Ger Cannoll - 5/20/2009

Still having a few issues with grandchildren on a listview. I more or less copied Edhy's suggestions to my own app , but grandchildren are still not displaying. I can navigate the Child ok ,but nothing is showing up on the Grand-child listview. It is also displaying an error if I double Click on any of the childen records on ListView 1. Screen attched. (It also shows up the error the first time I do a single click on one of the children records) . I am also attaching the code for the screen  (This uses similar structure to strataframe Sample with following BO names that I have used in my app ( Cust = SMA   Order=ITR  ORIT=IDE). The only other difference that I can see is that The Primary Key of My Customer File(SMA) is a string field rather than an int field .
By Trent L. Taylor - 5/21/2009

In the code that you provided, I don't see anywhere that you call the ListView2.Requery(). It is hard looking at an example like this as there is not much to go on since you did not provide a full sample. If you have a sample that illustrates this that you could share then please post that as it would be easier to work with.



The reason I am not sure exactly where to direct you as I don't exactly understand where your issue is. Setting up a parent->child->grandchild and event deeper relationship is something that we work with on a daily basis...including within ListViews. So at this point I know that it is just a matter of configuration. But I am not sure exactly at which point you are having the issue.



From just looking at your code, I see one issue here:



private void itR_BO1_Navigated(MicroFour.StrataFrame.Business.NavigatedEventArgs e)

{



if (this.itR_BO1.Count > 0)

this.idE_BO1.FillByParentPrimaryKey(this.itR_BO1.ITR_PK);



}




You never call the listview2.Requery(). Based on my assumption of your code, shouldn't the code read:



private void itR_BO1_Navigated(MicroFour.StrataFrame.Business.NavigatedEventArgs e)

{



if (this.itR_BO1.Count > 0)

this.idE_BO1.FillByParentPrimaryKey(this.itR_BO1.ITR_PK);



listview2.Requery();

}
By Ger Cannoll - 5/21/2009

Putting in the List2.Requery() has got a little further. Thanks. Now, I can get the grandchildren to display.

I had a porblem displaying the grandchildren as I scrolled up and down the Listview. I played around with the AutonavigateToSelected property  and the Tag field, and this is working now also.... is this yhe purpose of  this propery  ?

The only issue I have right now is how to flush out the Grandchild List, if there are no grandchilden for a partcular son e,g, the following sequence A son with Grandchildren, the next son has no grandchildren. etc. I initially had a if BO1.Count > 0, but then this was not refreshing the Grandchildren , leaving the grandchildren from the previous record. If I took this If BO1.Count out, I got an error message.What I have ended up doing, which works, is as follows:

this.idE_BO1.FillByParentPrimaryKey(0);

if (this.itR_BO1.Count > 0)

{ this.idE_BO1.FillByParentPrimaryKey(this.itR_BO1.ITR_PK); }

this.listView2.Requery();

i.e. I have filled first with a zero value

Is this the best way to do this

 

By Edhy Rijo - 5/21/2009

Gerard O Carroll (05/21/2009)
Is this the best way to do this




Yes, you want t run the List2.Requery() all the time so it can do just what is needed, show/remove records from the listview as per request.