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

column depends on another ForeignKey column

3 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Robert Madrian asked on 09 Jun 2016, 05:05 PM

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

3 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 13 Jun 2016, 08:22 AM
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
0
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
answered on 14 Jun 2016, 10:34 AM

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

0
Accepted
Konstantin Dikov
Telerik team
answered on 14 Jun 2016, 11:51 AM
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
Tags
Grid
Asked by
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Answers by
Konstantin Dikov
Telerik team
Robert Madrian
Top achievements
Rank 1
Veteran
Iron
Share this question
or