This is a migrated thread and some comments may be shown as answers.

Getting started with GridView, have a few questions

15 Answers 454 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Josh Anderson
Top achievements
Rank 1
Josh Anderson asked on 21 May 2008, 06:19 PM
I have just started working with the WinForms GridView, and I'm having some trouble getting a few things accomplished.  Sorry to jam all of this into one post, but I figure this might be most efficient.
  1. Is it possible to have the grid autosize rows?  I have several cells that are multiline text, but the grid doesn't automatically size so that this text can be seen.  Instead, it seems to display the middle of the text, which makes for a very crowded looking grid.
     
  2. I am binding to a List<T> containing my business object, which in turn includes a few List<T> properties containing other business objects.  I have built a project data source from which I have established the schema for the grid, but for some reason I can't get the grid to display the hierarchal data for the embedded List<T> properties.
     
    My data source recognizes them, and upon building the data schema I could see the ChildGridViewTemplates in my MasterGridViewTemplate, but these ChildGridViewTemplates did not have any columns on them.  I manually added some, but I'm still not getting any hierarchal data display.  Am I missing something?  Is there something I need to do differently since I'm using List<T> objects?
Thanks in advance for the help.

Josh

15 Answers, 1 is accepted

Sort by
0
Josh Anderson
Top achievements
Rank 1
answered on 22 May 2008, 06:43 PM
I have a few updates for the first question I posed:

I set the AutoSizeRows property to true, but this seems not to work perfectly.  With this property set, the control initially draws every row the same small size.  If I manually attempt to resize, the sizes of all the rows will instantly jump to a larger size, in most cases enough to accommodate the multi-line text.  This is one strange behavior that occurs repeatedly that is a problem.

In addition to that issue, the size that the rows expand to does not consistently contain all of the data in the multi-line cells.  In most cases the top and bottom are still clipped and even when they're not the cells appear to have no padding, with the text sitting right on a separating gridline.  This makes for a very difficult to read grid.

I haven't been able to get anywhere with the second question about hierarchal representation of business objects.

Josh
0
Abdul Razaq
Top achievements
Rank 1
answered on 23 May 2008, 03:58 AM
1. how could i bind cells to calculated fields?
2. how could i add unbound alongwith databound columns?
3. how could i add lookup field in a columns?
0
Martin Vasilev
Telerik team
answered on 23 May 2008, 03:45 PM
Hello,

Thank you for writing.

It seems that the AutoSizeRows property does not work properly when the column is not auto generated. We will address it in one of our future releases. Unfortunately, I cannot give you a workaround now.

John, I have updated your Telerik points for discovering this undesired behavior.

I have prepared a small example that demonstrates visualization of hierarchal data using a list of custom objects, adding unbound column and lookup column. You could find it attached. 

Please note that I have used BindingList<> instead List<> because it allows for a richer functionality in binding scenarios. 

Currently, RadGridView does not support calculated columns. However, the grid column could be bound to any type of DataSource columns, and you could realize the calculated field scenario as custom code.

I hope this helps. If you need additional assistance, do not hesitate to contact me again.

Kind regards,
Martin Vasilev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Josh Anderson
Top achievements
Rank 1
answered on 28 May 2008, 06:06 PM
Thanks for the sample project.  I'm not sure if that's worth implementing, though.  That example seems to suggest duplicating a data-style relationship when that is not exactly how my class is set up, nor do I want to change our business logic to more closely approximate our underlying data setup.

To provide a brief example, say I have two classes, a PhoneNumber class and a Customer class.  Here are some simple properties:

PhoneNumber Class
ID
Number
Description

Customer Class
ID
Name
Address
PhoneNumbers  <--  this is a List<PhoneNumber> property

If I have a List<Customer> object that I'd like to bind to my radGrid, I'd prefer that the radGrid simply see that one of the properties of the Customer object is itself a generic list and automatically understand the relationship.

With your example, it seems that I would have to consolidate all of the PhoneNumber objects in every Customer.PhoneNumbers property into one big List<PhoneNumber> object, then add a CustomerID property to my PhoneNumber objects in order to facilitate the hierarchy, or otherwise enable my business logic to pull all phone numbers and all customers separately.  In either case, it seems like an over-engineered problem, when the hierarchy is built into the classes.

I would think that any hierarchal gridview should be able to easily and automatically accommodate business objects with properties that are collections, arrays, hashtables, lists, etc.  Any chance this is something telerik will implement?

Josh
0
Martin Vasilev
Telerik team
answered on 30 May 2008, 02:23 PM
Hello Josh,

Thank you for getting back to me.

The scenario you have described is a many-to-many relation, because it is possible to add the same phone number for more than one customer. Currently, RadGridView does not support many-to-many relations and it is not possible to implement the scenario in bound mode.

Nevertheless, there is another alternative you might want to consider. If your data will not be edited, or have rows added or deleted from it, you can implement it in unbound mode. Unbound mode refers to the mode where you can add rows manually, without having them synchronized with an underlying data source. Basically, you can traverse the collections, and adds rows to the appropriate template manually.

Please consult our Unbound Mode example in the RadGridView section in the Examples application for further information on how to use the grid in unbound mode.

I hope this helps. If you have other questions, do not hesitate to contact me again.

Sincerely yours,
Martin Vasilev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Josh Anderson
Top achievements
Rank 1
answered on 30 May 2008, 02:33 PM
I guess the problem is that my scenario really shouldn't be viewed from a data paradigm.  The concept of "one-to-many" or "many-to-many" relationships doesn't really apply to my objects.  From the perspective of the data tier, constraints ensure that the Customer-PhoneNumber relationship is one-to-many, but that adds no real value in my business layer, hence the usage of List<T> properties.

I don't want to delve too deep into radGridView, but if each master object had a List<PhoneNumber> property with unique PhoneNumber objects, it would not be a many-to-many relationship anyway.

Unfortunately, manually managing the hierarchal layout in unbound mode isn't really worth it.  I'll likely just pursue another solution.  I am definitely a telerik fan and have used the controls (mostly in ASP.NET) for years, but in the interest of improving the Windows controls you might want to take a look at how Infragistics handles their grid -- it can accommodate the business object scenarios I've been discussing.  I just can't justify paying for a second suite of controls right now.  If telerik could learn something there and implement it in radGridView I think you'd have a winner.

Thanks,
Josh
0
Nikolay
Telerik team
answered on 02 Jun 2008, 02:11 PM
Hi Josh Anderson,

Thank you for the feedback.

Currently, RadGridView does not support binding custom business objects with nested collections to be shown in a hierarchy. This is a powerful feature, and it will be implemented in one of our upcoming releases.

If you have additional questions, do not hesitate to contact me again.

Kind regards,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Christian
Top achievements
Rank 1
answered on 19 Sep 2008, 07:20 PM
I agree Josh. This functionality is very important also for me. Is there a plan, when this functionality can be used?
Christian
0
Nikolay
Telerik team
answered on 23 Sep 2008, 04:36 PM
Hello Christian,

Thank you for your vote. I can assure you that we realize the importance of this feature. However, I cannot provide you with e specific time frame when it will be implemented.
 

All the best,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Erdal
Top achievements
Rank 1
answered on 19 Feb 2009, 06:20 PM
hi,

is this issue solved?
in my case i
have an Object
Bindinglist<UserObject>
Id
Name
Department
..
Department which is another object
  id
  name
...

Binding this to radgridview
..
  grdView.AutoGenerateHierarchyFromDataSet = true;
  gridViewBindingSource.DataSource = _dataSource;
  grdView.DataSource = GridViewBindingSource;
..
it works, but Department ist shown as "SimpleMasterData.Domain.ObjectModel.DepartmentObject"

i tried to set the Datamember value but it seems that the Parent Object "UserObject" can't be found
while grdView.Datamember = "Department" works fine but shows only child object data

Are thre any restrictions for Datamember ?
Trying to set "SimpleMasterData.Domain.ObjectModel.UserObject"
i get error "... Datamember property SimpleMasterData could not be found...
is everithing ignored after first  "."?

hope you can help me

erdal
0
Nikolay
Telerik team
answered on 23 Feb 2009, 06:02 PM
Hi Erdal,

Please note that the property which you set - AutoGenerateHierarchyFromDataSet - is valid only for DataSets, but not for lists of custom objects.

Currently, we do not support a hierarchy automatically build on a list of objects which have another lists of objects as properies. We have this feature request in our issue tracking system, but I cannot provide you with any specific time frame when it will be implemented.

For the time being, you can build the desired hierarchy manually by modifying your custom objects. Simply you should have:
  1. UserObject object with properties Id and Name.
  2. Department object with properties Id, Name and UserObjectId.

These custom object should be put into BindingLists collections. Then, you should relate the Department object to the UserObject by the UserObjectId property. I am attaching a sample project to demonstrate the approach. If you have additional questions, feel free to contact me.


All the best,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Erdal
Top achievements
Rank 1
answered on 23 Feb 2009, 08:31 PM
Hi Nikolay,

thanks for Your quik answer.
I will check, whether this solution will work for us.

I Think Your Grid would be really great if it could handle souch structures an showing them as hirachy
or better Userobject in the mainrow and DepartmentObject in ComboBoxColumn.

Your code works fine:
Sorry if i was unclear but most important for me is to use second Object (Department)in ComboboxColumn
because one User can only have one Department at a time

If i'd bind Data and add DepartmentColumn as comboboxColumn manually, could this new column substitute the old
auto generated Department Column reaguarding the Binding to Datasource an Updateevents?


Thank You

Erdal

0
Nikolay
Telerik team
answered on 26 Feb 2009, 05:11 PM
Hi Erdal,

Please refer to our documentation about GridViewComboBoxColumn for information about how you should set up such column.

Regarding the documentation article, your RadGridView should be bound to a collection of UserObjects and your manually added GridViewComboBoxColumn should be bound to a collection of Deparments. The UserObject class should have a property of type int called DepartmentId. The values for the GridViewComboBoxColumn will be taken from the DepartmentId data-bound column. If you do not want to show the DepartmentId column, you can set its IsVisible property to false.

In addition to our documentation, you can take a look at our Examples application, section RadGridView >> Column Types.

If you have additional questions, feel free to contact me.

Best wishes,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Erwin
Top achievements
Rank 1
answered on 09 Oct 2009, 11:16 PM
I confirm that the possibility to have sublists handled as hierarchical data would be much appreciated!
0
Nikolay
Telerik team
answered on 15 Oct 2009, 03:33 PM
Hi Erwin,

The latest version Q2 2009 SP1 still does not support subproperties in the hierarchical view. However, I am glad to inform you that we are working on a large change of the data layer which will enable this feature. We hope that we will be able to introduce the desired functionality in the upcoming Q3 2009 release or in its Service Pack 1.

Greetings,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Josh Anderson
Top achievements
Rank 1
Answers by
Josh Anderson
Top achievements
Rank 1
Abdul Razaq
Top achievements
Rank 1
Martin Vasilev
Telerik team
Nikolay
Telerik team
Christian
Top achievements
Rank 1
Erdal
Top achievements
Rank 1
Erwin
Top achievements
Rank 1
Share this question
or