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

[Solved] Foreignkey Column doesn't work in detail grid template

1 Answer 151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tiago
Top achievements
Rank 2
Tiago asked on 16 Sep 2014, 01:04 PM
Foreignkey Column doesn't work in detail grid template. Return Error template when I use the  columns.ForeignKey



<script id="templateConfiguracaoLimpezaLinha" type="text/kendo-tmpl">
        <%:     Html.Kendo()
                    .Grid<EditableConfiguracaoLimpezaLinha>()
                    .Name("GridConfiguracoes_#=Id#")
                    .ToolBar(toolbar => toolbar.Create())
                    .Editable(edit => edit.Mode(Kendo.Mvc.UI.GridEditMode.InLine))
                    .Columns(columns =>
                    {
                        columns.Bound(o => o.Id).Hidden(true);
                        //columns.Bound(o => o.GrupoLimpezaLinhaCodigo).Width(120);
                        columns.ForeignKey(o => o.GrupoLimpezaLinhaCodigo, (System.Collections.IEnumerable)this.ViewData["GruposLimpezaLinha"], "Value", "Text");
                        columns.Bound(o => o.LinhaProcessoId).Width(80);
                        columns.Bound(c => c.NumeroOrdem).Width(80).HtmlAttributes(new { style = "text-align: right" });
                        columns.Bound(c => c.SnAtivo).Width(80).HtmlAttributes(new { style = "text-align: center" });
                        columns.Command(command =>
                        {
                            command.Edit();
                            command.Destroy();
                        }).Width(100);
                    })
                    .DataSource(dataSource =>
                    {
                        dataSource.Ajax().Model(model => model.Id(m => m.Id));
                        dataSource.Ajax().Read(read => read.Action("Read_Configuracoes", "ConfiguracaoLimpezaLinha", new { itemLimpezaLinhaId = "#=Id#" }));
                        dataSource.Ajax().Create(create => create.Action("Create_Configuracao", "ConfiguracaoLimpezaLinha", new { itemLimpezaLinhaId = "#=Id#" }));
                        dataSource.Ajax().Update(update => update.Action("Update_Configuracao", "ConfiguracaoLimpezaLinha"));
                        dataSource.Ajax().Destroy(destroy => destroy.Action("Destroy_Configuracao", "ConfiguracaoLimpezaLinha"));
                        dataSource.Ajax().Events(ev => ev.Error("error_handler.bind({WidgetID: 'GridConfiguracoes_#=Id#'})"));
                    })
                    .Events(events =>
                    {
                        events.Edit("onEdit");
                    })
                    .ToClientTemplate()                     
        %>
    </script>

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 18 Sep 2014, 10:52 AM
Hi Tiago,

From the provided information it's not clear for us what is the exact reason for current behavior, however possible reason could be some of the values (passed to the ForeignKey column) to contain the "#" symbol (this symbol is used by Kendo UI template syntax and should be escaped). Could you please check if the values passed to the column contains this symbol?

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Tiago
Top achievements
Rank 2
Answers by
Vladimir Iliev
Telerik team
Share this question
or