column depends on another ForeignKey column

4 posts, 1 answers
  1. Robert Madrian
    Robert Madrian avatar
    96 posts
    Member since:
    Apr 2003

    Posted 09 Jun Link to this post

    Hello,

    I have the problem that one ForeignKey column depends on another ForeignKey column (see attached picture). As you can see the 
    columns "Fachgruppe" depends on value in column "Sparte" - now this is not correct because I don't know how to display only the
    values for "Fachgruppe" which depends on the current value of column "Sparte" in the row (for display and editing)?

    these are sample values for that columns
    Sparte     Fachgruppe
    1             1
    1             2
    1             3
    2             1
    2             2
    3             1
    3             2

    Is there a way to do this with MVC Grid?

    robert

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 13 Jun Link to this post

    Hello Robert,

    For achieving the desired result you should use Cascading DropDowns as demonstrated in the examlpe from following HowTo article:
    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Robert Madrian
    Robert Madrian avatar
    96 posts
    Member since:
    Apr 2003

    Posted 14 Jun in reply to Konstantin Dikov Link to this post

    I do not mean the edit but the display in the grid row as columns.ForeignKey...

    what if the second ForeignKey column "Fachgruppe" depends on the value of the first ForeignKey column "Sparte"?

    columns.ForeignKey(p => p.Sparte_ID, (System.Collections.IEnumerable) ViewData["Sparte"], "Sparte_ID", "Sparte").Title("Sparte").Width(200);
    columns.ForeignKey(p => p.Fachgruppe_ID, (System.Collections.IEnumerable) ViewData["Fachgruppe"], "Fachgruppe_ID", "Fachgruppe").Title("Fachgruppe").Width(200

    robert

  5. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 14 Jun Link to this post

    Hello Robert,

    The ForeignKey column matches values to text and the value must be a field from the underlying data source. If your logic for the values is not determined by a single value you should change the schema of your data and modify the values that you are binding to the Grid, so that you could match each text to a single value.

    If you have any other questions on this matter, please provide a real example with your tables data and how you need to connect the values.


    Regards,
    Konstantin Dikov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready