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

ForeignKey column not showing dropdown when column is edited

7 Answers 506 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Larry
Top achievements
Rank 1
Larry asked on 01 Aug 2014, 03:57 PM
I have been pulling my hair out for the past two days on something that should be basic.    I have a grid using the ForeignKey to display a foreign key field.   When I open the screen all of the items with a existing foreign key assigned get interpreted correctly and show the Name column, not the key.   But, when I edit the column it shows the key with no combo.   Code snippets are in the attached file.

I am sure it is something simple, but I cannot figure it out.

Any help will be appreciated.





















7 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 05 Aug 2014, 10:02 AM
Hi Larry,

From the provided code it appears that the ForeignKeyColum is not using the default editor template - in this case you should make sure the project contains the defined "Resource_ItemEditor" view and it's nested under the "EditorTemplates" folder. For more information about the editor templates you can check the following help article:

Kind Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Larry
Top achievements
Rank 1
answered on 05 Aug 2014, 02:10 PM
I do have a custom editor called Resource_ItemEditor in the EditorTemplates folder.   Here is the Editor.

@model object

@(
 Html.Kendo().DropDownListFor(m => m)
            .DataTextField("Name")
            .DataValueField("Resource_Item_Key")
            .DataSource(d => d.Read(r => r.Action("GetDropDownList", "Resource_Item")))

)
@Html.ValidationMessageFor(m => m)


0
Vladimir Iliev
Telerik team
answered on 06 Aug 2014, 06:47 AM
Hi Larry,

I tried to reproduce the problem locally but to no avail – everything is working as expected on our side. For convenience I created small project which replicates your scenario and works as expected on our side - could you please check it and let us know how it differs from your real setup? This would help us pinpoint the exact reason for this behavior.

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Tino
Top achievements
Rank 1
answered on 18 Jun 2015, 08:02 AM

Hi.

Vladimir, why in your sample project, dropdown is not displayed in popup mode?

Thx,

Tino.

0
Vladimir Iliev
Telerik team
answered on 18 Jun 2015, 09:52 AM
Hi Tino,

In order to be shown in the "PopUp" editor of the Grid you should set the "UIHint" attribute over the model field:

public class Order
{
    [UIHint("Resource_ItemEditor")]
    public int EmployeeID { get; set; }

Regards,
Vladimir Iliev
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
Tino
Top achievements
Rank 1
answered on 18 Jun 2015, 10:03 AM

Thank you for your prompt reply.

Does this mean that we need always to put UIHit for default template also ?

 

Tino.

0
Vladimir Iliev
Telerik team
answered on 19 Jun 2015, 07:26 AM
Hello Tino,

Yes - for the PopUp editor of the Grid you should set the "UIHint" attribute even for the ForeignKeyColumn as the editor is build by calling the "Html.EditorFor(action)" helper.

Regards,
Vladimir Iliev
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
Larry
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Larry
Top achievements
Rank 1
Tino
Top achievements
Rank 1
Share this question
or