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

Make a Hiearchy View on RadGridView

3 Answers 110 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nesim
Top achievements
Rank 2
Nesim asked on 26 Mar 2009, 09:16 PM

Hi,

I am developing a Media Solution Application as a Windows Program in Visual Studio 2008 and MsSql Server 2008. The problem is there are a lot medias. I have to organize that medias in unlimited groups like a nested relation. A media can repeat in many groups or repeat in playlist by itself with no group. Let me try to tell you in tables.

Medias
---------------------------------------
MediaID
Media
MediaType (Enum=> Group=1 , Media=2)
.
.
.

MediaGroupMedias
----------------------------------------
MGMID
MainGroupID
MediaID
.
.
.

Let's insert some data.

Medias
----------------------------------------
MediaID  Media                       MediaType
1              Bamboleo                2
2              Spanish Guitar        2
3              Hips Don't Lie          2
4              How you remind me 2
5              Clips                        1
6              Pop                          1
7              Rock                        1

MediaGroupMedias
---------------------------------------------------
MGMID  MainGroupID  MediaID
1                  5               6
2                  5               7
3                  6               1
4                  6                2
5                  6                3
6                  7                4

As you see we can make a huge playlist. It seems  No problem in that db design but in practice but i couldn't show this structure on gridview in a hiearchy view. I want to show like a treeview but on the grid. I was unavaliable to show on grids. I tried on DataGridView & RadGridView (Q3 2007). So i have to find out a new solution for that.  New solution looks like:

The tables are Media, Groups and GroupMedias.

Medias
---------------------------------------
MediaID
Media
.
.
.

Groups
----------------------------------------
GpID default (0) // 0: for nonegroup medias
MainGPID default (0): is main group
.
.
.

 

GroupMedias
-------------------------------------------
GpID
MediaID
.
.
.

And in the end i need a playlist table. That would be like below.

Playlist
---------------------------------------------
PID
MediaID Default (0) //if 0 then it's a group
GroupID Default (0) //if 0 then it's a media

So,
i have a few questions :)

-In that structure is it possible to make an hiearchy view on gridview?
 if so how? (Should i create datatables in runtime?)
-Is there another better solution? ( i think there will be more than one)
 if you can offer i will appricate you. :)

Thanks in advance.
Bests

 

 

3 Answers, 1 is accepted

Sort by
0
gerbrand
Top achievements
Rank 2
answered on 27 Mar 2009, 11:05 AM
Hi Nesim,

I think you need to do it programmatically.

First you should create a query that retrieves your hierarchy and read it into an List<object>.

After this you just loop the List and add it.

I'm doing it like this and it works. You can check the helpfile of the radgridview under the content: "Hierarchical Grid" -> "binding to Hierarchical Data Programmatically".



0
Julian Benkov
Telerik team
answered on 31 Mar 2009, 09:16 AM
Hello Nesim,

Sorry for delay of answer.

For this scenario you can use RadGridView and set AutogenerateHierarchy property to true. You can create a typed DataSet with your data and relations and then set the DataSource and DataMember of RadGridView.

Also you can use the Gerband approach and make List<> or BindingList<> generic collections with your objects and manually add GridviewTemplates in RadGridView.

If your scenario is different, please review the source code of the RadGridView Hierarchy example, which is shipped with the installation.

 
Sincerely yours,
Julian Benkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Nesim
Top achievements
Rank 2
answered on 01 Apr 2009, 06:08 AM
Hi,

No problem for delay. It's ok. I have already tried to like that,

 

 

 

              
 
            taCat.Fill(dtCategories);  
        
 
 
            DataSet ds = new DataSet();  
            ds.Tables.Add(dtCategories);  
 
 
 
            DataRelation dr = new DataRelation("aa", dtCategories.Columns["CategoryID"], dtCategories.Columns["MainCategoryID"]);  
            dr.Nested = true;  
 
 
 
            ds.Relations.Add(dr);  
 
 
            ds.WriteXml("C:\\nested.xml");  
 
            //DataSet dsr = new DataSet();  
            //dsr.ReadXml("C:\\nested.xml",XmlReadMode.ReadSchema);  
 
            radGridView1.AutoGenerateHierarchyFromDataSet = true;  
 
            radGridView1.DataSource = ds;  
            radGridView1.DataMember = "Categories";  
 

But  it wasn't show on radGridView or .net grid. So i driven my own treegrid following this article. Now i did what i need.  

Thanks for your insteresting.
With my bests.
Tags
GridView
Asked by
Nesim
Top achievements
Rank 2
Answers by
gerbrand
Top achievements
Rank 2
Julian Benkov
Telerik team
Nesim
Top achievements
Rank 2
Share this question
or