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

[Solved] Server Edit Templates and Entity Framework

0 Answers 43 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.
Fernando
Top achievements
Rank 1
Fernando asked on 04 Oct 2010, 10:16 PM
I am trying to implement Telerik Grid bound to Tarefas Entity following server edit templates demo. I expected that after clicking update the grid would send to the update action both row key (tarefa) and foreign key pessoa. In demo sample view code is:
<asp:content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
  
<%= Html.Telerik()
        .Grid(Model)
        .Name("Grid")
        .DataKeys(keys => keys.Add(o => o.OrderID).RouteKey("Id"))
        .DataBinding(dataBinding => dataBinding.Server()
           .Update("UpdateOrder", "Grid"))
        .Columns(columns =>
        {
            columns.Bound(o => o.OrderID).Width(100);
            columns.Bound(o => o.Employee).Width(230);
            columns.Bound(o => o.OrderDate).Width(150);
            columns.Bound(o => o.Freight).Width(220);
            columns.Command(commands => commands.Edit()).Title("Edit").Width(200);
        })
        .Pageable()
%>
</asp:content>

The key of o.Employee is passed as second parameter to the UpdateOrder Action.
My code is similar:
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Tarefas>>"  %>
  
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>
  
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%: ViewData["Message"] %></h2>
    <p>
        To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc<;/a>.
    </p>
    <%= Html.Telerik()
        .Grid(Model)
        .Name("Grid")
        .DataKeys(dk => dk.Add(t => t.Tarefa).RouteKey("id"))
        .DataBinding(dataBinding => dataBinding
            .Server()
                .Select("Index", "Home")
                .Update("Update", "Home")
                )
        .Columns(columns =>
        {
            columns.Bound(o => o.Tarefa);
            columns.Bound(o => o.Data); //.Format("{0:dd/MM/yy}");
            columns.Bound(o => o.Horas);
            columns.Bound(o => o.Pessoas);
            columns.Bound(o => o.Descricao).Title("Descrição");
            columns.Command(c => c.Edit()).Title("Edit").Width(200);
        })
        .Pageable()
%>
  
</asp:Content>

But the o.Pessoas key is not sent as second parameter as in demo sample. Am I missing something?

Tags
Grid
Asked by
Fernando
Top achievements
Rank 1
Share this question
or