Hierarchial Datagrid (Creating Parent-Child relationship)Hierarchial Datagrid (Creating Parent-Child relationship)
Old forum URL: forums.lhotka.net/forums/t/2092.aspx
Inquistive_Mind posted on Monday, January 08, 2007
Hello All,
I am fairly new to CSLA and right now working on a prototype to check the feasibilty of the framework.I need to create a Hierarchial Grid display of items.
Right now I have three BO's
Editable Root
Editable Child
Editable Child Collection.
I need to display the root objects first and when the user clicks on the primany key field of the root object displayed on the grid its respectives children objects should be listed. My other problem was my database tables have int as the datatype for the primary keys and it uses the auto incrementing feature to create the unique primary key.For the children object I was able to handle it using the technique posted at http://www.onelittlevictory.com/ but for the parent root object Iam not quite sure how to go about it.especially in the Dataportal_Create method.
Any information,help regarding binding objects to get a hierarchial display and creating objects using int as the dattype for primary key fields would be great.
PS: Im using Infragistics Datagrids and not regular ASp.Net Datagrids.
Thanks in Advance,
V
Brian Criswell replied on Monday, January 08, 2007
I am assuming that you root objects should also have a grid, although
that seems to be missing from your example. If you are doing
that, you would also need EditableRootList for your list of root
objects for the user to select one. You could then handle the
CurrentChanged event on the binding source to set the DataSource on the
BindingSource for the child DataGridView.
A lot of people here would consider adding a list of read only objects
for getting the minimal information needed for the user to select which
one they want to edit from the list. So you would have
RORootList and RORoot. When the user selects one of the items in
the list, the UI then loads the corresponding EditableRoot.
However, your choice of which path to take depends on your use case.
As for presetting the id property, one way that people have gone about
that is to set the id value to a constantly decrementing negative
number. There was a thread with examples for this.
EDIT: Oops. I just noticed that you are in a web
environment. Some of the concepts in the second paragraph may
help you, but I imagine that someone else will pop in and steer you in
the right direction.
Inquistive_Mind replied on Monday, January 08, 2007
Thanks Brian for the info.will try you suggestions and will post it :-)Inquistive_Mind replied on Tuesday, January 09, 2007
So that means I would require Editable Root,Editable Root Collection for n number of Parents and editable child ,editable child collection for n number of children?Brian Criswell replied on Thursday, January 11, 2007
My idea was more along the lines of:
For selecting the item to edit:
RORootList - Load this from the database. It contains a list of
RORoot - Thi contains just an id and description. The user selects one of these and the user interface uses the id to load
EditableRoot - Loaded from database using id of the item selected by the user. Contains all edit fields.
EditableChildList - Contains a list of
EditableChild - A child of the EditableRoot contains all fields needed to edit the child.
Inquistive_Mind replied on Thursday, January 11, 2007
Thanks again Brian.But for my prototype I want both the Parent List and the Child List to be loaded automatically and then there is only one grid.I am usinf Infragistics controls and it has a Viewtype propoerty Hierarchila.If the object is created properly then automatically the grid displays it as a Parent Child relationship.Another requirement is that the data access should happen in one hit.So the RORoot object when created should create its children based on its ID.
I am able to create this behaviour using ASP.net grid but there I have two adapters for Parent and Child respectivly and I populate the dataset and creat the relationship in the UI code. Automatically the grid dispalys a hierarchy.I want this behaviour with CSLA objects and thats where I am stuck.
Thanks Again,
V
Inquistive_Mind replied on Thursday, January 11, 2007
Hello,
Finally I was able to create the Parent child Relationship and bind it to the Infragistic grid as a Hierarchial Dispaly.Thanks for all your help.
V
Copyright (c) Marimer LLC