CollectionElements of a Collection of Collections as ItemSource

Hi together,

iam the new one here :D

I have a "small" Problem, iam trying to bind a collection of elements to a datagrid and trying to access the elements of the nested collection to the datagrid. Is that possible?

Maybe a mini example

public class Example1CollectionElement
    {
        public int Example1ID{ get; set; }
        public Example2Collection Examples2 { get; set; }
}

Example1Collection test = GetAllExamples1();

DataGrid.ItemSource = test

How to show for each Example1CollectionElements all Example2CollectionsElements in the Grid without using a List or a SubGrid?

I hope my question is understandable :D

Greetings Patrick




3 Replies 1 reply marked as answer

AR Arulpriya Ramalingam Syncfusion Team September 16, 2020 05:18 PM UTC

Hi Patrick, 
 
Thank you for using Syncfusion products. 
 
We are unclear of your requirement that to show the nested collections to load in the GridControl in flat grid (to show all the columns in main grid itself). Please share us some image representation of your exact requirement and confirm that whether you are using SfDataGrid for WPF or GridControl. So that, we could analyze further to provide you a better solution at the earliest. 
 
Regards, 
Arulpriya 



PA Patrick September 16, 2020 06:24 PM UTC

Hi Arulpriya,

the requirment or the reason i want to build it this way, is the complexity of the collection it self. The collection looks like this
  • person
  • personProp1Collection
  •      personProp1PropCollection
  •           personProp1PropPropCollection
  • personProp2Collection
It represents the hole Database and is generated on application start. So i hope to reduce the loading time during runtime. But to show or to edit some child,child,child Collections i need to show them in a SfDataGrid.

I tried it this way <syncfusion:GridTextColumn MappingName="PersonProp1.PersonProp1ID" HeaderText="PersonProp1ID"/>

But with that it only work if i use

Datagrid.ItemSource = person[index]

But i want to show

<syncfusion:GridTextColumn MappingName="PersonProp1.PersonProp1ID" HeaderText="PersonProp1ID"/>

that for all Persons without loading it in a list.

The reason behind that construct is the that i dont want to update the hole collection of collection during the runtime. Just safe it to the Database and working in the lokal storage.

I hope that explains it better, if not, maybe i need to search someone that can translate my problem xD

Greetings,

Patrick


AR Arulpriya Ramalingam Syncfusion Team September 17, 2020 06:02 PM UTC

Hi Patrick, 
 
Thank you for the update. 
 
We suspect that you are trying to achieve ComplexProperty binding and ViewDetails. We already provided the details in our user guide and please make use of the below UG link for further details. 
 
 
please get back to us, if you need any further assistance. 
 
Regards, 
Arulpriya 


Marked as answer
Loader.
Up arrow icon