We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Can a hierarchical DataBoundGrid be bound to IList source?

Thread ID:





15207 Jun 14,2004 08:00 PM UTC Jun 15,2004 07:29 AM UTC WinForms 5
Tags: GridControl
Asked On June 14, 2004 08:00 PM UTC

I have a need to create a hierarchical grid like in the samples, but my data will not be coming from a straight forward DB query. For each cell, I will need supporting information that I''ll keep somewhere in an object hierarchy. I would like to bind the hierarchical grid to my own set of classes that are derived from IList, and then each cell could be backed by my own internal data in the class. I can bind a single-level DataBoundGrid to IList source as in the samples, but can this be done to create a hierarchical grid? If not, another idea: If my DataSet that contains DataTables contains my own Objects in the rows and columns....what method/interface does the object have to support for the DataBoundGrid to get/set the data for a particular cell? I tried supporting ToString(), thinking that it would be called to render the data for a cell, but that''s not working, which makes sense...there has to be a way for the grid to SET the data in the DataTable cell when the grid cell changes as well. Thanks for any help...

Administrator [Syncfusion]
Replied On June 14, 2004 08:10 PM UTC

You can display an hierarchical custom collection in a GridDataBoundGrid. Take a look at the Grid\Samples\DataBound\Hierarchical\Customers sample.

Replied On June 14, 2004 08:50 PM UTC

Many thanks Clay - I''m looking at it now. Follow up question: My objects don''t have pre-defined properties such as FirstName, LastName that would layout as column names across the top. The number of columns and their names are dynamic at runtime based on external data. Are the properties on the IList derived object the only way the grid knows how to get data from the object? Is there anyway the grid can get data from the underlying objects by INDEX instead of by PropertyName? Thanks!

Administrator [Syncfusion]
Replied On June 14, 2004 09:43 PM UTC

You can have your IList object implement ITypedList to expose exactly the objects you want to see from your collection. Or, you can dynamically set property types at runtime also using a ITypedList implementation. Here is a sample of this latter idea. ITypedListDataSourceSample_3885.zip

Replied On June 14, 2004 10:10 PM UTC

Excellent - thanks Clay, almost there... :) Now the last piece: I have the ITypedList based collection to bind to a given grid. How do I make the 2nd and 3rd grid relationships for the hierarchical to work out? (the latest enclosed sample produces a single flat grid) In the standard DataSet based hierarchical grid, I can use DataSet.Relations.Add, then add a corresponding Binder.AddRelation that matches that. Without a DataSet around, what "relation" do I give to the Binder in the ITypedList scenario? Thanks!! Great product.

Administrator [Syncfusion]
Replied On June 15, 2004 07:29 AM UTC

I think you would use the property name of teh child IList property. This is how the hierarchy is set up in the Grid\Samples\DataBound\Hierarchical\Customers sample.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon