Adding more than one relationship to RadGrid in code

2 posts, 0 answers
  1. Ken
    Ken avatar
    4 posts
    Member since:
    Mar 2011

    Posted 18 Nov 2016 Link to this post

    Hello,

    I have a hiearchal radgrid with a parent level that has 2 key columns.

    For example:

    ID, Sequence, first_name, last_name

    This can result in data that looks like the following:

    1, 1, John, Doe
    1, 2, Adrian, Shepard
    2, 1, Mary, Jane

    That child level has:

    ID, Sequence, Data

    So you can have data that looks like the following:

    1, 1, 0.256
    1, 2, 0.944
    2, 1, 0.109

    How can I code the grid so that the child level uses both ID and Sequence as a composite key when the radgrid is built entirely in code?

    At the moment I use:

    relationFields = New GridRelationFields()
    relationFields.MasterKeyField = "ID"
    relationFields.DetailKeyField = "ID"
    tableView.ParentTableRelation.Add(relationFields)

    How do I code it so that it references both ID and Sequence as the relationship so that the grid looks like:

    John, Doe
         0.256
    Adrian, Shepard
         0.944
    Mary, Jane
        0.109

    instead of:

    John, Doe
         0.256
         0.944
    Adrian, Shepard
         0.256
         0.944
    Mary, Jane
        0.109

    which is wrong, since it is repeating the values on 2 rows because they share the first part of the relationship instead of also considering the second column.

    I've looked in the documentation but the only information I've found on creating a composite key relationship involved doing so in the HTML, which is not an option for me as the radgrid is 100% generated in VB code on the server side.

    Thanks for any assistance.

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2259 posts

    Posted 22 Nov 2016 Link to this post

    Hello Ken,

    I have replied to your query in the support ticket you have submitted and suggest we continue the conversation there. Give the suggestions a try and let me know how they work for you.

    With that said, please avoid submitting duplicate threads. This will enable us to keep better track of your support history and provide answers faster.


    Regards,
    Viktor Tachev
    Telerik by Progress
    Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Back to Top