Binding BOs to EnhancedList with Parent-Child relationship.


Author
Message
Lukasz Kustusz
Lukasz Kustusz
StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)
Group: Forum Members
Posts: 29, Visits: 125
Hello,

I'm quite new to Strataframe Framework. I installed the trial version just yesterday. I'm working on a log viewer project that would represent log records from the DB using the DevExpress gridview (which is the EnhancedList wrapper from the SF). 

The way my DB tables are structured are quite simple. I have three different logs that I'd like to represent in my grid. I have a MasterTable with PK = Rec_ID and LogType_ID, and I have 6 other tables, one for each log type. The MasterTable contains fields common to all logs, like time, user, etc. Each log table also has a Rec_ID, and LogType_ID. I also have a LogTypeDescription table with two fields (LogType_ID, LogDescription) with 6 records in it, each describing different log type.

I've created my BOs, one for each of the tables defined above, and I defined relationdhips between them using ParentRelationship property. Relationships are simple: MasterTable is the parent to all other tables, linking on the Rec_ID, LogType_ID.

I'd like to be able to see those relationships represented in the grid using its Master-detail view, where master records would be expandable showing a different view depending on the type of log.

I was able to bind my MasterTable to the grid (Using BusinessBindingSource bound to the Mastertable), but the relationships are not detected. I've already done something similar using embedded ADO.NET dataset, and it works fine, but I'd like to se if strataframe can do similar tricks. Form the DevExpress documentation I know that in order for the Master-Detail view to work I have to Master-Detail: DataTable specific names for the TableAdapters, ie. AdapterTable1, AdapterTable2 etc (This is in Windows Forms Components > Products > XtraGrid > Concepts > Master-Detail Overview > Binding to Data Specifics > Master-Detail: DataTable Use of the DevExpress documentation)

-> How can I do this with EnhancedList and BOs?

-> Do I have to use BusinessBindingSource, and if not how should I set up the binding?

-> How can I specify that the LogType_ID from every BO be "replaced by" LogDescription from the LogTypeDescription BO? 

-> Is there a way for a BO to  represent a join of two tables?

Thanks,

Lukasz

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Lukasz.

Take a look at the posts from here, they can help you:

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

Also, the BOs can represent a view. So if you build a view wich represents your join, you can just create a BO and map it to the view.
Lukasz Kustusz
Lukasz Kustusz
StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)
Group: Forum Members
Posts: 29, Visits: 125
Thank you for your answer. Unfortunatelly I don't see how this applies to EnhancedList. It is not groupped the same way as XtraReport is. Instead it uses relationships to set-up the GridView structure at design-time. One way suggested was to use DataSets extracted from BOs to do the binding. If I do that, why use strataframe at all? Using views, is also quite combersome, as it forces me to set up all the GridViews at runtime, as opposed to using the extensive features of the EnhancedList's Designer tool. Also I need my application to be able to add/update rows, which is risky using views.



Here's the form as designed with ADO.NET (RunTime)http://forum.strataframe.net/Uploads/Images/bb35ecb3-72bc-43f0-a3bb-912b.png:

And Here's how it looks like at RunTime. Notice the ADO.NET adapters and the View structure in the Designer.

http://forum.strataframe.net/Uploads/Images/96845432-9991-4fa5-acc2-80d2.png

Am I the first to use EnhancedList to represent parent-detail structure? Can it be done with StrataFrame at design time, as it is using ADO.NET DataSets?
Edited 14 Years Ago by Lukasz Kustusz
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
Thanks for your interest in StrataFrame.  As you well know, there are a lot of philosophies in application development, and many times there is more than one way to skin the proverbial cat.  First of all, you would bind using a BusinessBindingSource to the grid.  This provides direct multi-row .NET data binding and is the most appropriate tool for binding to a grid.  Ultimately you would be able to manage your complex configuration.

As for the purpose of StrataFrame, I am almost not sure the best way to answer.  StrataFrame has so much depth and performs so many tasks that purchasing StrataFrame just for the purpose of binding to a grid is kind of like buying a 747 for the peanuts BigGrin.

StrataFrame handles everything from the UI all the way back through to the DAL (Data Access Layer).  It also manages your relationships from an object model perspective and will even propagate this back to the database for you.  By defining your parent-child relationships, the BOs will automatically handle foreign key values and make sure that they are persisted.  So that is one of many benefits that would pertain to your current situation.

StrataFrame is designed to work with 3rd party tools, such as DevExpress, though when working with these tools and understanding the logic behind the 3rd party aspect, you will have to get support from the said 3rd party as StrataFrame users use so many different tools that it is not possible for us to be a support expert in each tool.

As I previously mentioned, there are a lot of philosophies in development, and one is...no offense here...not to be so grid complex.  We have some tools that make short work of parent-child UI.  To begin, our ListView in conjunction with a ChildFormDialog.  This is a quick and simple way to manage child tables with RAD functionality and is generally more user friendly in the end.  StrataFrame was created from our need to produce an extremely massive medical application.  We do use some grids now and then, but we have learned that leaning too heavily on grids can become an end-user issue but also a development issue.  In short, you can do just what you are trying with StrataFrame, but I would recommend taking a look at some other ways to tackle this problem as I think that you will have more positive results all the way around.

Again...this is just my opinion, but that is one great thing about this forum, we all share our experiences and opinions and come out the better for it...as does StrataFrame as we really try to listen!!!
Lukasz Kustusz
Lukasz Kustusz
StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)
Group: Forum Members
Posts: 29, Visits: 125
Thank you, Trent. I do see your point, to avoid grid-central design, but in this case I'm convinced that this is the way to go due to the built in, drag-and-drop grouping and sorting functionality, filters, etc. The application that I'm trying to develop is just a small module of a future redesign of our LMS software. If I'm successful in implementing this with SFBOs I'd go on to use SF platform for all our future development. So I'll need all of the 747, peanuts included BigGrin

Now, as I wrote initially, I do use BusinessBindingSource, but it seems that the relationships between my BOs are not detected, because the EnhancedList displays only the Parent object. 

I do seem to understand the logic behind the grid, because I use it successfully with ADO.NET datasets in this capacity, as depicted on the screenshots.



Anyway, if you thinks SF BOs can do what  I need them to do, I'd appreciate some specific help. Otherwise, thanks for sharing.
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Lukasz.

I went ahead and downloaded DevEx to create a quick sample on how to use the BusinessBindingSource to accomplish a Parent-Child grid situation. You might find the name of my BBSs strange, since I used a sample I had written before on how to accomplish this on a report, and that's why I directed you to those posts when you had the impression that they had nothing to do with what you were asking for. Anyway, this sample has the same principles and uses a DevEx Grid, which is the control that the EnhancedList inherits from, so if you tweak the grid you will probably get the results you want. Here is the link:

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

Hope it helps in some way.

Cheers.
Lukasz Kustusz
Lukasz Kustusz
StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)
Group: Forum Members
Posts: 29, Visits: 125
Thank you very much for the sample, I'm eager to try it out. I imagine it uses some sample database to which your BOs are mapped. Could you tell me where I can get a copy of this sample DB?
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
It uses the StrataFrame Sample database that is installed with the SF framework. So you should already have it on your SQL Server.
Lukasz Kustusz
Lukasz Kustusz
StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)StrataFrame Beginner (49 reputation)
Group: Forum Members
Posts: 29, Visits: 125
Thank you again for all your support. I've rebuilt my project according to the structure in your sample and it does work. Interestingly it only works with the original DevExpress DataGrid. When I tried to use the SF EnhancedList instead, the entire grid was not visible (of course, the Visible property was true).

Now, there's another question that I'd asked initially, that I'm trying to solve:

-> How can I specify that the LogType_ID from every BO be "replaced by" LogDescription from the LogTypeDescription BO?

In your example this would be equivalent to having a Customer Type where each rec in Customer table would have something like CustomerType_ID, and there would be another table, CUstomerTypeTable, with two fields (CustomerType_ID ,CustomerTypeDescription). 

What I need is to show the CustomerTypeDescription instead of CustomerType_ID in my grid.
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
You are welcome, Lukasz.

To accomplish what you asked, I would add an unbound column to the grid, if DevEx lets you do it. I use Infragistics, and in situations like that this is what I do. After adding the unbound columns into the grid, I use its InitializeRow event, for example, to set the column value for that current row. It would look something like this:

Private Sub myGrid_InitializeRow( _
    ByVal sender As System.Object, _
    ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) _
    Handles myGrid.InitializeRow

        '-- check if there are rows to be initialized
        If Me.myGrid.Rows.Count() = 0 Then
            Exit Sub
        End If

        '-- move record point to current row
        MyGridBO1.SeekToPrimaryKey(e.Row.Cells("my_pk").Value)

        '-- get information from foreign table
        LogTypeDescriptionBO1.FillByPrimaryKey(MyGridBO1.LogType_ID)
  
        '-- if found, set caption
        If LogTypeDescriptionBO1.CurrentRowIndex < 0 Then
            e.Row.Cells("unboundcontro_CustomerTypeDescription").Value = RetrieveTextValue("MyLocalizationKey - NotFound")
        Else
            e.Row.Cells("unboundcontro_CustomerTypeDescription").Value = LogTypeDescriptionBO1.CustomerTypeDescription
        End If

End Sub

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