Binding BOs to EnhancedList with Parent-Child relationship.


Author
Message
Lukasz Kustusz
Lukasz Kustusz
StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 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

Replies
Lukasz Kustusz
Lukasz Kustusz
StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 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 (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K 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 Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 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 (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K 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 Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 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 (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K 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

Lukasz Kustusz
Lukasz Kustusz
StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)
Group: Forum Members
Posts: 29, Visits: 125
Thank you for your comment. I tried it but it doesn't work exactly as expected. I added an unbound column to the parent view and populate it in the CustomColumnDisplayText like so:


Private Sub GridView2_CustomColumnDisplayText(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs) Handles GridView2.CustomColumnDisplayText
        If GridView2.RowCount = 0 Then
            Exit Sub
        End If
 
        If e.Column.FieldName = "Type" Then
            BoMasterLogType1.SeekToPrimaryKey(e.Value)
        End If

        If BoMasterLogType1.CurrentRowIndex >= 0 AndAlso e.Column.FieldName = "colTypeDescription" Then
            e.DisplayText = BoMasterLogType1.Type_Description
        End If
End Sub



I call the FillAll method of BoMasterLogType1 in Form_Load.

It seems to work as far as the display is concerned, ie every row now has the correct LogDescription in the custom column. But it's not working when I drag the LogDescription column to the Group by section. It only shows one log type at a time - the one that's in the curernt row. Grouping by any of the bound columns works fine, ie. all possible values are shown.

Forgive my ignorance, but shouldn't this linking be done in the Buisness or even Data tier? Is it not possible to link two BOs to produce this effect (like a BO join)? If I wanted to replace grid by a form with text boxes, and I wanted to show the description field instead of ID for any given type or category of a BO, do I have to handle it in the interface like this every time?
Lukasz Kustusz
Lukasz Kustusz
StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)
Group: Forum Members
Posts: 29, Visits: 125
   See previous post
Edited 15 Years Ago by Lukasz Kustusz
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
That is the way I usually go. On the grid, you probably need an event for the Row Initialization.
Lukasz Kustusz
Lukasz Kustusz
StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)StrataFrame Novice (53 reputation)
Group: Forum Members
Posts: 29, Visits: 125
Thanks Ivan, I finally solved the issue with some support from the DevXpress. The problem was with the test for rowcount=0 at the begining of the above procedure: Here's the full description of my solution: http://www.devexpress.com/Support/Center/p/Q275267.aspx

I still think that this type of join should be handled at the business layer, though. In SF forums I found some posts where this is mentioned:

http://forum.strataframe.net/Topic25388.aspx
http://forum.strataframe.net/Topic3321.aspx
http://forum.strataframe.net/Topic5719.aspx

There seems to be several ways, like using DB Views, or dummy ddt profiles, or updating custom fields in the interface (my case). They all seem to have some drawbacks, especially when BOs must be updatable. In contrast, using ADO.NET, while being a more manual approach, does provide a possibility to construct DataSets from joins, with custom UPDATE, DELETE, and INSERT statements if necessary.

 My situation is special in that I'm just testing the StrataSphere out (using the trial version for almost a week) to see if it can give us an advantage over using other frameworks (I'm also evaluating MereMortals, DevExpress) or just sticking to self-developed n-tier approach with ADO.NET in all our future developments. 

At the moment I'm undecided. Let me ask you this:

Is there a plan to support BO joins in the near future?

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
As Trent has written to you before, StrataFrame covers many different tasks and this might be the diferential to help you make your decision.

About the future plans and features, I wouldn't be able to tell you about your specific question at the moment, but will try and find out with the developers.

Anyway, I am glad you got your problem solved. Wink
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Lukasz Kustusz - 15 Years Ago
Ivan George Borges - 15 Years Ago
Lukasz Kustusz - 15 Years Ago
Trent L. Taylor - 15 Years Ago
Lukasz Kustusz - 15 Years Ago
                         Hi Lukasz. I went ahead and downloaded DevEx to create a quick sample...
Ivan George Borges - 15 Years Ago
                             Thank you very much for the sample, I'm eager to try it out. I imagine...
Lukasz Kustusz - 15 Years Ago
                                 It uses the StrataFrame Sample database that is installed with the SF...
Ivan George Borges - 15 Years Ago
                                     Thank you again for all your support. I've rebuilt my project...
Lukasz Kustusz - 15 Years Ago
                                         You are welcome, Lukasz. To accomplish what you asked, I would add an...
Ivan George Borges - 15 Years Ago
                                             Thank you for your comment. I tried it but it doesn't work exactly as...
Lukasz Kustusz - 15 Years Ago
                                             See previous post
Lukasz Kustusz - 15 Years Ago
                                                 That is the way I usually go. On the grid, you probably need an event...
Ivan George Borges - 15 Years Ago
                                                     Thanks Ivan, I finally solved the issue with some support from the...
Lukasz Kustusz - 15 Years Ago
                                                         As Trent has written to you before, StrataFrame covers many different...
Ivan George Borges - 15 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search