Child ListView


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I have a Maintenence Form with two tabs, On the first tab I show the Parent Record and on the second tab I have  a List View , where I want to show the children. I want the children refreshed each tme the parent changes. I have both Parent and Child business Objects set up.

I have the method (on the ListView)  set as FillByparentPrimaryKey(System.Int32) and PopulateOnFormLoad set to manual.

I reckon I need to call the FillByParentPrimaryKey() somewhere to refresh the children and am wondering where is the best place to put this code. I could be refreshing ,either using the navigation buttons, Adding a new Parent,Deleting a parent or  doing a search etc.

Also, is just calling FillByParentPrimaryKey() sufficient or do I also need to call any Refresh() code

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Gerard O Carroll (05/07/2009)
I have a Maintenence Form with two tabs, On the first tab I show the Parent Record and on the second tab I have a List View , where I want to show the children. I want the children refreshed each tme the parent changes. I have both Parent and Child business Objects set up.



I have the method (on the ListView) set as FillByparentPrimaryKey(System.Int32) and PopulateOnFormLoad set to manual.



I reckon I need to call the FillByParentPrimaryKey() somewhere to refresh the children and am wondering where is the best place to put this code. I could be refreshing ,either using the navigation buttons, Adding a new Parent,Deleting a parent or doing a search etc.



Also, is just calling FillByParentPrimaryKey() sufficient or do I also need to call any Refresh() code




Hi Gerard,



You can put code like this in the ParentBO.Navigated() event:

Private Sub BizTransaction1_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles BizTransaction1.Navigated

Me.lstTransactionItems.Requery()

End Sub





Also in your ListView.ListPopulating() you have to have something like this:



Private Sub lstTransactionItems_ListPopulating(ByVal e As MicroFour.StrataFrame.UI.ListPopulatingEventArgs) Handles lstTransactionItems.ListPopulating

If Me.ParentBO.Count > 0

e.Parameters(0).Value = Me.ParentBO.PrimaryKeyFieldValue

Else

e.Parameters(0).Value = 0

End If

End Sub






Edhy Rijo

Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Edhy. Many thanks for your detailed response.

I have input code as suggested bu am getting a message on the Requery code;

Dynamically populating the ListView Failed. Could not create and fill the business object of type.....

When I look a t the detail, there seems to be some issue converting a string to a GUID

-------------------  My Code is as follows ------------------------------------------------------------------

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

        {

                 if (this.smA_BO1.Count > 0)

            { e.Parameters[0].Value = this.smA_BO1.PrimaryKeyField.ToString(); }

            else

            { e.Parameters[0].Value = "zahaha"; }

         }

 

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

{ this.listView1.Requery();}

-------------------------------------------------------------------------------------

In the Method To Execute.. I am not clear on what GUID refers to. My primary key happens to be a Char(10) field

Am I ciorrect in using a FillByParentPrimaryKey(Guid) here .... not sure what a GUID is ??

Also in code above, not sure if This.SmaBO1.PrimaryKeyField.Tostring() is correct ?

 


Attachments
ListView PopulationSettings.png (92 views, 44.00 KB)
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
The problem is the PrimaryKeyField is the name of the primary key field...not the value. Use the PrimaryKeyFieldValue property or use bo.CurrentRow(bo.PrimaryKeyField). The later will definitely need a conversion to work, not sure on the former...never noticed that property before! Likely it is strong typed though.
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Greg. thanks for replying

I cannot see a property called PrimaryKeyValue. Tried GetPrimaryKeyValue() but same error. Also tried , as a test , putting in a string , as an actual value which is one of the primary keys,  ({ e.Parameters[0].Value = "A001"; } but still get the same error on the requery.

The error message detail says--> Object of type System String cannot be converted to type 'System Guid'. It looks like its trying to convert the string(e.g. A001) to GUid. I assume this is because I have the ListView Population Settings.MethodToPopulate as FillByParentPrimaryKey(GUID). Is it correct to use this Method if the Primary Key is of type Character


Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Gerard,

I am not aware of a "PrimaryKeyValue" property, but you don't need one, just use the field value like I showed you before in my sample code and the sample application posted.

You are getting the error, because you have a String type PK not a GUID type, so probably if you change the Method to Execute in the ListView Population Settings to "FillByParentPrimaryKey(Object)" may do the trick, I have not used it that way, but if that does not work, you can always either create your own method to populate the listview or even overwrite one of the existing methods to get the data the way you want.



Also another method you can use to populate a listview is the "CopyDataFrom(BusinessLayerBase,BusinessCloneDataType)", I belive that is the one used in the combobox sample I uploaded and it does requred you filling up a BO dropped in your form and the listview will simply copy the data from that BO into its internal BO to populate itself.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Gerard,

The Value properties of the event args in the ListPopulating event are Object which will accept a Guid value.  It is not necessary to ToString this value if your PK is in fact a Guid.  This woudl be the first thing that I woudl change.  Secondly, what is the stack trace and exception of the error you are getting?

Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I changed to FillByParentPrimaryKey(Object) and this is now working fine, can see the children. Thanks for all your assistance

I can understand why you would use a FillByParentPrimaryKey(Int) but when would you use GUID ?? I am unclear as to what a GUID is, other than this would be a term used for a surrogate type key . 

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
A GUID is a defined type that is in teh below format (in most cases):

4d9895f1-7d0d-4003-9a28-389624b36c58

This is used in instances when you may need to use replication as it makes the synchronization of primary keys far easier.  If you can avoid using GUIDs for PKs you are better off as there is more overhead.  But this one general purpose of using a GUID.  There are other uses as well, but for the intent of this converstaion that would be one of the few uses.

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