StrataFrame Forum

Master and details devexpress grid wuth SF BO

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

By Chan - 10/26/2007

Hi,

Any sample code to show how to have master and details BOs shown in XtraGrid (in same grid)?



Thank you
By StrataFrame Team - 10/30/2007

Same grid meaning multiple bands within the grid?
By Paul Chase - 10/30/2007

Chan,

Here is how I am doing it.

By Robin J Giltner - 11/1/2007

Thats pretty cool.  Thanks for the example Paul.

Robin Giltner

By Paul Chase - 11/1/2007

Yeah I like it it is great for reports as well, I have an editable version as well, It is almost complete  still have a few minor things but for the most part it works
By Peter Jones - 11/1/2007

Hi Paul,

I didn't understand what Chan was getting at so I couldn't help but I certainly have an interest in Master/Detail and DevExpress so I was keen to see what you have done. I opened the project but it gave me an error (illegal form or some such thing). Paul would you be good enough just to post a screen shot of what the form looks like.

Cheers, Peter

By Paul Chase - 11/2/2007

Peter,

I'm not sure why would have an issue unless maybe you have a different version of Dev Ex installed. maybe if you remove and re-add the dev ex references it will work.

Anyways what I did was create a class that inherits from dataset so I can then drag and drop business objects onto it and it adds them to the dataset so you end up with a typed datset with relations etc. So far it works well for me I am not doing any zillion recrods grids or reports so there could be some issues.

 

Now I have a typed data set in my toolbar that contains whatever business objects I dropped onto it. I can then drag and drop it onto a form or report and use it as a data source.

If I drop it on a form with a Dev Ex grd I can assign it as the data source

and datamember

The end result is a grid with master child navigation

or a report with child bands

By Peter Jones - 11/2/2007

Hi Paul,
Thanks for that. The screen shots are bit hard to read but I think I get the picture and yes indeed this is very interesting. I will revisit the project you sent and get it to work (I'm 7.2 DevEx as well so its not that). It looks as though you have got DevEx's inbuilt parent/child facilities working using standard BO's. When I looked at doing this some time ago I gave up because it looked as though I would have to dump the SF BO's and create a hierarchical dataset in code and manage it myself.

Again, thanks for the very prompt response - much appreciated.

Cheers, Peter

By Peter Jones - 11/2/2007

Hi Paul,

I saw 7.2 and I thought our versions where the same but you are 7.2.2 while I'm still using 7.2.1. Anyway I can see things now and what you've done looks really good - I will certainly take a much closer look because the inbuilt Parent/Child stuff in DevExpress always seemed like a very clean UI to me. A couple of questions though:

1) When I look in the code I see only boCustomer is exposed. Could all the bo's be dropped on the form and everything would work ok?

2) In the screen shots I see the SF toolbar is on the form. Does that work ok in whatever grid view has focus?

3) I take it the general flow is the BOs are populated as normal and, within DataSetBase (very clever BTW), the relations are created (using info from the BOs) and the data loaded for use in the various grids. If this is so how do changes in DsCustomerOrders dataset make their way back into the BO's for saving to the database?

Cheers, Peter

By Chan - 11/3/2007

Hi,

Thank you for sample.

I have tried it, but VS keep complaining it is not typed dataset. (I attached the code)

I also tried to add your sample project to my solution, and add to my form (difference project). VS unable to locate the sample dataset while trying to add item to toolbox.



Any ideas?



Thank you
By Paul Chase - 11/5/2007

Hi Peter,

Glad you figured out the versioning thing Smile kinda thought it was something like that

I think all of your questions are things I have added after I posted the sample app, At first the basic idea was to be able to use the dataset class with Xtra Reports and for read-only master-Detail grids to allow a "drill down" capability. I was mainly interested in being able to have access to all the strong typed fields at design time because it makes report design alot easier and I was happy with that!

After having some issues with the business binding source I decided to try to make this dataset class stay in sync with the business objects (read-write),anyways I think I have it working for the most part but it may still be a little bit buggy I don't remember where I left off Friday but I'll try to post what I have so far  a bit later today if I can.

Paul

Peter Jones (11/02/2007)
Hi Paul,

I saw 7.2 and I thought our versions where the same but you are 7.2.2 while I'm still using 7.2.1. Anyway I can see things now and what you've done looks really good - I will certainly take a much closer look because the inbuilt Parent/Child stuff in DevExpress always seemed like a very clean UI to me. A couple of questions though:

1) When I look in the code I see only boCustomer is exposed. Could all the bo's be dropped on the form and everything would work ok?

2) In the screen shots I see the SF toolbar is on the form. Does that work ok in whatever grid view has focus?

3) I take it the general flow is the BOs are populated as normal and, within DataSetBase (very clever BTW), the relations are created (using info from the BOs) and the data loaded for use in the various grids. If this is so how do changes in DsCustomerOrders dataset make their way back into the BO's for saving to the database?

Cheers, Peter

By Paul Chase - 11/5/2007

Chan,

The project doesn't have the business objects that you are using in the dataset so I can't easily see what the issue is.

Are you saying the dataset does not show up on your toolbox?

Here are the steps that should make this work

Create a class that inherits from datasetbase

drop business objects on the new class

override relations if needed

Rebuild solution

should have new class in toolbox,

drag new class onto form or report from toolbox and set data source and member

By Chan - 11/5/2007

hi,

I have reattach another sample.



Thank you.
By Paul Chase - 11/5/2007

ok i'll try to take a look at it
By Trent L. Taylor - 11/5/2007

Paul's example and description of how to use a multi-detail band on any environment relying on the IList interface is very good.  It thought I would also share what we do.  We take a slightly different approach and this is how we create our strong-typed data sources for reporting and grids.

Let's take the report approach as this will be what I believe everyone is trying to accomplish here.  We have a reporting assembly that has a data source for each report that we create.  Our base data source inherits off of the BusinessBindingSource, we also inherit the BO we plan to use off of the primary BO so that we can add any custom fields without making a mess of the original BO.

Public Class MyReport_CustomersBO
    Inherits CustomersBO

'-- Add any custom Fill methods to retrieve data specific to the report (supports INNER JOINS, etc)

'-- Add any custom fields that may be specific to the report

End Class

Public Class MyBaseDataSource
    Inherits BusinessBindingSource

Private _ReportBO As New MyReport_CustomersBO

Public Sub New()
    '-- Attach the data source to the binding source
    Me.BusinessObject = _ReportsBO
End Sub

End Class

By Paul Chase - 11/5/2007

Trent,

Does that allow you to do master detail binding?

In other words

Customer-->

                  Orders-->

                                 Order Items

By Trent L. Taylor - 11/5/2007

Yes, you can chanin these together.  So you may have a CustomersBBS and a CustomerOrdersBBS.  Within the CustomersBBS you can create a property that exposes the CustomerOrdersBBS.  There are two hitches that you have to account for.  First, the private field that exposes the child needs to be shared and second, you have to manually filter out the child records when returning the child object.

Public Class CustomersBBS
    Inherits BusinessBindingSource

Private Shared _CustomerOrdersBBS As New CustomerOrdersBBS()

Public ReadOnly Property CustomerOrders
    Get
        '-- Filter out the child records
        _CustomerOrdersBBS.BusinessObject.Filter = "or_cust_pk=" & Me.BusinessObject.cust_pk.ToString()

        '-- Return the filtered BO
        Return _CustomerOrdersBBS
    End Get
End Property

End Class

This is what we do for all of our reporting and have some very deep and complex relationships and it has worked out great!

By Paul Chase - 11/6/2007

Trent,

I got really busy yesterday so wasn't able to spend much time looking at this. Is there anyway you can create a sample of how to use the BBS to create a master detail grid?

I had some issues using the BBS as a binding source that was discussed in another thread. Ben gave me some good suggestions on how to get around the issues I faced but I ended up using this approach to grid binding as it meant I did not have to refactor and then retest quite a bit of logic.

Anyways it would be great to see an sample of how it would work using a BBS.

Paul

By Trent L. Taylor - 11/6/2007

I will see if I can't get a sample created for the next build so that it is a bit more in-depth.  This is the approach that we use and it has worked well.
By Paul Chase - 11/6/2007

Peter,

I got really busy yesterday so didn't have a chance to post this, this is an editable version of the data set class, basically what I am trying to do is to keep the business objects on the form in sync with the data tables in the data set. 

For the most part I think it will work ok but there still may be some gotcha's I haven't ran across. I also threw in a report so you can see how that works.

Anyways I hope this helps out anyone that is looking to do this sort of thing. 

I also am posting an infragistics 2007 volume1 version just cause it was easy enough to do Smile.

Paul

By Chan - 11/7/2007

Hi,

After created BBS, how to set it to xtragrid to show master details?



Thank you
By Chan - 11/8/2007

Hi,

I finally able to make xtragrid recognize my dataset and relations of my dataset. However, when I set datamember of gridview, it prompted error 'child list can not be created'



Any ideas?



Thank you
By StrataFrame Team - 11/8/2007

Is there an InnerException to that exception?  It might give you more info as to why it was unable to create the list.
By Chan - 11/8/2007

Ben Chase (11/08/2007)
Is there an InnerException to that exception? It might give you more info as to why it was unable to create the list.




Hi,

I still failed to configure xtragrid to show "+" sign using BBS as suggested. What should I set so that xtragrid grid know it is master and details?



In my previous post, I mentioned IO able to configure xtragrid, is using DataSetBase provided by Paul Chase. Sorry for confusing.
By Paul Chase - 11/9/2007

Chan the inner exception still would be helpful to see what is going on, I never had any errors like the the one you describe so am not sure what would cause it

I know you converted the code I did into C# so maybe something got messed up in the conversion?

The samples you sent earlier are not very helpful to me, can you try to replicate the project I created in VB using the strataframe sample database?

Paul

By Richard Keller - 12/11/2007

Trent,

Have you embedded a Report Writer into your application to that users can create their own reports?  I am evaluating your recommendation for Report-Shooter now and look forward to your sample.  If you have any Report-Shooter samples that would help.

Richard

By Trent L. Taylor - 12/12/2007

Have you embedded a Report Writer into your application to that users can create their own reports? 

Yes. In fact, in our medical software we created an entire report template interface and we develop our reports through the VERY same engine that we make available to our end users.  Obviously there are certain features that they cannot access since we may want to restrict certain things, but the engine and editor is literally the same one for the end-user as it is for us.  This makes is VERY easy to copy over a report and make a few simple changes out in the field.

They can then click the Design template to modify the template.

If you have any Report-Shooter samples that would help.

We are planning on including a more robust sample in the next update.  But I have attached a very simple sample that I created for someone else that will at least give you a clue as to how to setup a data source and tie it into a report.  The one we will release will include more details as it relates to paret-child relationships, etc.

By Richard Keller - 12/12/2007

Thanks I think that the Report Template Editor and project would be a fine addition to the Strataframe Extended UI set.  

Thanks,

Richard

By Trent L. Taylor - 12/12/2007

This may be something that we offer down the road, but the integration may vary from application to application as there would be a lot of "gray area."  Creating just the editor portion is actually very easy.  But integrating the report engine to support your applications need for the dialogs that pop-up to acquire parameters, etc. would be more difficult.  Not that it couldn't be done, but it will definitely be something that becomes a consideration as another module that could be purchased.

For now we are going to create a number of samples that show how to implement this type of logic into the application using SF through samples and some KB articles.