Entity + Entity.SubCollection binding to DataGrid

Posts   
 
    
Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 28-Jan-2015 12:30:12   

I have a colection of Entities called "KoffersMeetklemmen", this entity is shown in a DataGrid.

This datagrid is extended with collumns of the collection "KoffersInstallatiedelen". "KoffersInstallatiedelen" is part of entity "KoffersMeetklemmen"

"KoffersInstallatiedelen" is dynamic and not fixed for each "KoffersMeetklemmen"

How can i solve this?

1) Can i use partial class properties with a parameter like:

Partial Class KoffersMeetklemmenEntity

    Public ReadOnly Property KoffersInstallatiedelen(ByVal aIdx As Integer) As String
        Get
            If Me.KoffersInstallatiedelen IsNot Nothing AndAlso aIdx < Me.KoffersInstallatiedelen.Count Then
                Return Me.KoffersInstallatiedelen.Verhoudingsfactor.ToString
            Else
                Return String.Empty
            End If
        End Get
    End Property

End Class

2) Is it possible to extend "KoffersMeetklemmenEntity" dynamicaly with "KoffersInstallatiedelen" fields ?

3) ?

Attachments
Filename File size Added on Approval
Model.png 130,390 28-Jan-2015 12:30.29 Approved
Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 28-Jan-2015 17:19:41   

When you say:

"KoffersInstallatiedelen" is part of entity "KoffersMeetklemmen"

Do you mean they are related? If so, could you please specify the type of relation?

If it's a 1:m relation since you say: "collection "KoffersInstallatiedelen"". Then you should either have a nested grid or 2 grids to display the master-detail data.

If the relation is m:1 or 1:1, then a simple property mapped onto the related entity's property is a good option as you specified in the first approach.

Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 28-Jan-2015 17:47:55   

Correctly it is a 1:m relation and it would be obviously to have a nested grid or 2 grids to display the master-detail data but ...

We like to have the "KoffersInstallatiedelen" as collumns added to "KoffersMeetklemmen" items in the DataGrid.

What i did as workaround, but not a nice work around, is to define x number of "KoffersInstallatiedelen" properties in de partial class of "KoffersMeetklemmen". I'm looking for a dynamic way to handle this.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Jan-2015 07:27:20   

Having a 1:m relation in a grid as additional columns seems very unusual and not easy to see. So, if you found a workaround, use it. It would be the same case with other objects, not entities necessarily, so it's not a LLBLGen subject per-se.

Another option is to build your columns dynamically, at code, as long as your grid control allows you to do that.

David Elizondo | LLBLGen Support Team
Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 29-Jan-2015 08:01:28   

daelmo wrote:

Having a 1:m relation in a grid as additional columns seems very unusual and not easy to see.

In our case users like it to see it that way, in this case, so it is easy to see for them!

What I understand from the comments this problem could not be solved with LLBLGen?

To get a better understanding of LLBLGen I like to have an awnswers on the following question: "It is possible to extend a Entity in a partial class; can I do something with the parameter of a property?"

It is possible to solve my problem with triggers on the gridview, or I can write a stored procedure to solve this, but I like to do it in LLBLGen, because we like to do as less as possible in de database (more convenient to have the source on one place).

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 29-Jan-2015 18:06:14   

You can indeed use partial classes to extend an entity, as I noted earlier.

LLBLGen provides DynamicLists and TypedLists to let you fetch a flat list of data (read only). This can be handy in your case.

P.S. I still don't know how you are going to display fields from a collection in a one cell in a grid. Are you picking the top/first entity in the collection?

Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 30-Jan-2015 09:58:10   

Thanks for answering.

Walaa wrote:

P.S. I still don't know how you are going to display fields from a collection in a one cell in a grid. Are you picking the top/first entity in the collection?

simple_smile I don't add them in one cell. For each entity in the collection I add a Column. This is also the main problem related to LLBLGen! With help of triggers, provided by devexpress datagrid, I show the content in de cells. The trigger CustomColumnDisplayText is fired for each cell and in the corresponding function I calculate the value to display.

Please take a look on the screeshot of the datagrid, so you can see how it looks like. The first 5 columns are from "KoffersMeetklemmen" and the last three are from "KoffersInstallatiedelen" (dynamic). The last three columns are added to the gridview dynamically and I have to use events to display the text and to store the entered text.

Walaa wrote:

LLBLGen provides DynamicLists and TypedLists to let you fetch a flat list of data (read only). This can be handy in your case.

This can be usefull, but i have to investigate this.

Attachments
Filename File size Added on Approval
DataGrid_Dynamic columns.png 41,522 30-Jan-2015 09:58.25 Approved
Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 30-Jan-2015 10:03:44   

How to call a property in the partial class with an argument? Is reflection the way to do this?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 30-Jan-2015 17:33:54   

How to call a property in the partial class with an argument? Is reflection the way to do this?

Could you please demonstrate what you need to accomplish via pseudo code?

Meindert
User
Posts: 63
Joined: 07-Nov-2012
# Posted on: 03-Feb-2015 09:26:53   

I figured out that what I need is not to be solved with LLBLGen. Because I'm not capable to make my needs understandable, with the limitations of programming lang. in my mind, I think that I can't espect this from an entity relation model.

In DevExpress it is possible to implement UnBounded Columns. A trigger is fired for each cell "CustomUnboundColumnData" that could be used to Get/Set data from/in the dynamic entity collection (part of the main entity).

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 03-Feb-2015 16:48:32   

Ok, if you need further assistance, let us know simple_smile I'm closing this thread for now, if you need it to be reopened, just post a new message in this thread.

Frans Bouma | Lead developer LLBLGen Pro