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

[Solved] ForeignKey in Grid as DropDownList - Selection Problem

5 Answers 157 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Maciel
Top achievements
Rank 1
Maciel asked on 23 Apr 2012, 12:53 PM
I have a grid with a foreignKey control as DropDownList

columns.ForeignKey((o => o.Id), (IEnumerable)ViewData["Id"], "Id", "Text");

the grid editing mode is InCell

When I click in a grid and select the value for the first time, doesn't work, afterwards is works fine.

The similar case happened hear, but in WinForms:
http://www.telerik.com/community/forums/winforms/dropdownlist-and-listcontrol/first-selection-attempt-for-raddropdownlist-fails-afterwards-is-works-fine.aspx

I tried to find a solution, but nothing until now.

Thanks for your help.

5 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 25 Apr 2012, 12:13 PM
Hello Maciel,

I am not sure what exactly is the problem. Could you please elaborate what exactly goes wrong and if possible provide a small demo project so we can check the problem on our side and search for a solution?

Regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Maciel
Top achievements
Rank 1
answered on 25 Apr 2012, 12:58 PM
Here it is.

I find a problem and a parcial solution.

The problem is when the Bound column with the property hidden(true) was added before the ForeignKey column.

When you change the order, adding the hidden Bound column after the ForeignKey column was worked fine.

Thanks for your support.
0
Petur Subev
Telerik team
answered on 30 Apr 2012, 11:29 AM
Hello again Miciel,

Thank you for sending a sample project. I reproduced the problem you experience and it seems it is somehow related to the hidden column defined before the ForeignKey column. 
If you define your columns so the hidden one is not the first everything seems to be working fine.
e.g.
.Columns(columns =>
{
    columns.ForeignKey((o => o.Id), (IEnumerable)ViewData["Id"], "Id", "Text");
    columns.Command(commands =>
    {
        commands.Delete().ButtonType(GridButtonType.Text);
    });
    columns.Bound(o => o.Key).Hidden(true);
})

I will inform our Dev team for that issue. Also I updated your telerik points as a small sign of our appreciation.

Regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Patrick
Top achievements
Rank 1
answered on 01 May 2012, 07:12 PM
We have the same issue.

I have downloaded the test project of Maciel and if you take out the Command column you have the same weird behavior.

<%= this.Html.Telerik().Grid<TelerikMvcApplication1.Models.ClassTest>()
    .Name("Test")
    .DataKeys(keys => { keys.Add(p => p.Id); })
    .ToolBar(commands =>
        {
            commands.Insert().ButtonType(GridButtonType.Text);
        })
    .DataBinding(dataBinding => dataBinding.Ajax()
        .Select("Select", "Home"))
    .Columns(columns =>
        {
 
            columns.ForeignKey((o => o.Id), (IEnumerable)ViewData["Id"], "Id", "Text");
 
        })
    .Pageable(p => p.PageSize(10))
    .Editable(editing => editing.Mode(GridEditMode.InCell))
    .KeyboardNavigation()
%>



We have the same problem. We would like to use the ForeignKey without COMMAND and having the FK in the first column. How can we fix that?
0
Patrick
Top achievements
Rank 1
answered on 01 May 2012, 07:28 PM
Here is a third bug with this ForeignKey control:

If you set with HtmlAttributes a class you will have to double select like if you had a hidden field or if you doesn't have command in the row. very weird:

    <%= this.Html.Telerik().Grid<TelerikMvcApplication1.Models.ClassTest>()
        .Name("Test")
        .DataKeys(keys => { keys.Add(p => p.Id); })
        .ToolBar(commands =>
            {
                commands.Insert().ButtonType(GridButtonType.Text);
            })
        .DataBinding(dataBinding => dataBinding.Ajax()
            .Select("Select""Home"))
        .Columns(columns =>
            {
 
                columns.ForeignKey((o => o.Item), (IEnumerable)ViewData["Id"], "Id""Text").HtmlAttributes(new { @class="myCustomClass"});
                columns.Bound(o => o.Key).Hidden(true);
                columns.Command(commands =>
                {
                    commands.Delete().ButtonType(GridButtonType.Text);
                });
            })
        .Pageable(p => p.PageSize(10))
        .Editable(editing => editing.Mode(GridEditMode.InCell))
        .KeyboardNavigation()
    %>
Tags
Grid
Asked by
Maciel
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Maciel
Top achievements
Rank 1
Patrick
Top achievements
Rank 1
Share this question
or