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

[Solved] Automatic Hiarchy From IEnumerable .Net Object

6 Answers 202 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Richard
Top achievements
Rank 1
Richard asked on 30 Apr 2009, 06:48 PM
Hi,

I'm using the SilverLight 3 binaries.

I set the radGridViews ItemSource to an IEnumerable .Net object but it does not render as a hiarchy.  What happens is that the column(s) that are List<ClassName> show as System.Collections.Generic.List[ClassName] instead of showing as the next band in the hiarchy.   I cannot provide any code help here with templates or other possible techniques since all queries are dynamic and when executed reuse the same data grid.  I need the Grid Control to render the hiarchy based soley on the context of the IEnumerable object.  Also, I have a problem when I set the ItemSource to another IEnumerable object where the previous contents used grouping.  I guess the basic question is how to I reset the Grid back to the initial state with nothing in it?

Thanks
Rich

6 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 04 May 2009, 02:35 PM
Hi Richard,

Although we are not currently in the phase of supporting officially Silverlight 3, I am curious and will be happy if I can find a way to help you. 
I will be happy if I can get from you a sample project resembling the issues. Also , have you tried this under Silverlight 2 ? 
 
Finally a way to 'reset' the RadGridView is to set the ItemsSource to null as well as clear the GroupDescriptions and SortDescriptions  collections. I am not sure this will help in your case until I can see some sample code of the way you are binding the RadGridView.
Hope that helps.

Sincerely yours,
Pavel Pavlov
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
Richard
Top achievements
Rank 1
answered on 04 May 2009, 04:25 PM
Hi Pavel,

I'm not able to provide the project since the Silverlight client is getting the data from a WCF service that I have developed and it would be a bit to complicated to also include the web service.

Please try the code at the end of this post with some program that sets ItemSource.  The output should look as follows

- Honda
    Civic
    Accord

I think what you will get is

Honda | List<Model>

This works with the Infragistics silverlight datagrid and I hoping this will work with Telerik.  Your grid at present has many more features that I want but the ability to create a hierarchy from the provided classes is a show-stopper for me.  I have no idea what will be coming in as data an need the datagrid to handle the hierarchy  The other issue I have with the Telerik grid is the scrolling performance which I'm sure is being improved but maybe you can talk about efforts to improve performance. 

My other question was I am going to change the ItemSource numerous times in the same instance of the datagrid and I want to reset the datagrid back to the first instantiated value prior to setting ItemSource.  I can do this without problem until I make use of the group function.  After using the group function the next time ItemSource is loaded the program crashes.

I love your stuff,  please tell me what I can do to accomplish the above.

Thanks
Rich

---Try something like this ------------------------------------------------------------------------
public
class TelerikTest

{

 

public TelerikTest()

 

{

 

    List<Car> cars = new List<Car>();

 

 

    Car car = new Car();

 

    car.CarName =

"Honda";

 

 

    Model model = new Model();

 

    model.ModelName =

"Civic";

 

    car.Models.Add(model);

    model =

new Model();

 

    model.ModelName =

"Accord";

 

    car.Models.Add(model);

   telerikGrid.ItemSource = cars;

}

}

 

public class Car

 

{

 

    public String CarName = String.Empty;

 

 

    public List<Model> Models = new List<Model>();

 

}

 

public class Model

 

{

 

    public String ModelName = String.Empty;

 

}

0
Vlad
Telerik team
answered on 07 May 2009, 10:28 AM
Hello Richard,

Straight onto your questions:

1) You can create property hierarchy similar to this example:
http://demos.telerik.com/silverlight/#GridView/Hierarchy/PropertyHierarchy

Here is an example for your case:

 GridViewTableDefinition detailDefinition = new GridViewTableDefinition();
 detailDefinition.Relation = new PropertyRelation("Models");
 telerikGrid.TableDefinition.ChildTableDefinitions.Add(detailDefinition);
 telerikGrid.ItemsSource = cars;


2) Scrolling performance will be greatly improved for our Q2 release - you can contact us via support ticket and we can send you our latest build.

3) You need to clear GroupDescriptions property to avoid this similar to this example:
http://demos.telerik.com/silverlight/#GridView/DataSources

Don't hesitate to contact us if you have other questions.


Kind regards,
Vlad
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
Richard
Top achievements
Rank 1
answered on 07 May 2009, 03:26 PM
Hi Vlad

If i had another two classes under "Models" called "Engines" and "Colors"  would the code look as follows or do I need to sssociate Engines and Colors as children of Models?

Thanks
Rich

 GridViewTableDefinition detailDefinition = new GridViewTableDefinition();
 detailDefinition.Relation = new PropertyRelation("Models");
 telerikGrid.TableDefinition.ChildTableDefinitions.Add(detailDefinition);

 detailDefinition = new GridViewTableDefinition();
 detailDefinition.Relation = new PropertyRelation("Engines");
 telerikGrid.TableDefinition.ChildTableDefinitions.Add(detailDefinition);

 detailDefinition = new GridViewTableDefinition();
 detailDefinition.Relation = new PropertyRelation("Colors");
 telerikGrid.TableDefinition.ChildTableDefinitions.Add(detailDefinition);


 telerikGrid.ItemsSource = cars;

0
Vlad
Telerik team
answered on 08 May 2009, 06:33 AM
Hello Richard,

You can find small example application attached.

All the best,
Vlad
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
Richard
Top achievements
Rank 1
answered on 08 May 2009, 03:39 PM
Hi Vlad,

That was a great support effort, its exactly what i need....concise and to the point.  Anyone not clear on how to display hierarchical query results should download this.

Many Thanks

Rich
Tags
GridView
Asked by
Richard
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Richard
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or