Make a Hiearchy View on RadGridView

4 posts, 0 answers
  1. Nesim
    Nesim avatar
    7 posts
    Member since:
    May 2008

    Posted 26 Mar 2009 Link to this post

    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

     

     

  2. gerbrand
    gerbrand avatar
    78 posts
    Member since:
    Mar 2009

    Posted 27 Mar 2009 Link to this post

    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".



  3. UI for WinForms is Visual Studio 2017 Ready
  4. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 31 Mar 2009 Link to this post

    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.
  5. Nesim
    Nesim avatar
    7 posts
    Member since:
    May 2008

    Posted 01 Apr 2009 Link to this post

    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.
Back to Top