Hi there,
I am having some problems to create a Master/Detail Grid on ASP.NET MVC
The connection to the SQL Database is created with Linq-to-sql, so I have the model. I have created two functions in the controller to get the data from the DB.
I am following the example shown here: http://demos.kendoui.com/web/grid/hierarchy.html
but is not working :/
here is my ASPX code:
here is my controller code:
and the model is being created with the Linq-to-Sql.
I have tried everything .. but I dont get the selection button and the detail.
It would be very nice if you can give me a hand.
Thanks in advance.
I am having some problems to create a Master/Detail Grid on ASP.NET MVC
The connection to the SQL Database is created with Linq-to-sql, so I have the model. I have created two functions in the controller to get the data from the DB.
I am following the example shown here: http://demos.kendoui.com/web/grid/hierarchy.html
but is not working :/
here is my ASPX code:
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h3>Users</h3>
<br />
<%: Html.Kendo().Grid<PaysmardService.Models.Users>("Users")
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.FirstName).Width(110);
columns.Bound(e => e.LastName).Width(110);
columns.Bound(e => e.Country).Width(110);
columns.Bound(e => e.City).Width(110);
columns.Bound(e => e.Title);
})
.Sortable()
.Pageable()
.Scrollable()
.ClientDetailTemplateId("template")
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Server()
.PageSize(6)
.Read(read => read.Action("Users", "Home"))
)
.Events(events => events.DataBound("dataBound"))
%>
<script id="template" type="text/kendo-tmpl">
<%: Html.Kendo().Grid<PaysmardService.Models.Phones>("Phones")
.Name("grid_#=ID#")
.Columns(columns =>
{
columns.Bound(o => o.PhoneNumber ).Width(100);
columns.Bound(o => o.IsBlocked ).Width(110);
columns.Bound(o => o.IsEnabled);
columns.Bound(o => o.DeviceType ).Width(200);
})
.DataSource(dataSource => dataSource
.Server()
.PageSize(5)
.Read(read => read.Action("Phones", "Home", new { ID = "#=ID#" }))
)
.Pageable()
.Sortable()
.ToClientTemplate()
%>
</script>
<script>
function dataBound() {
this.expandRow(this.tbody.find("tr.k-master-row").first());
}
</script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h3>Users</h3>
<br />
<%: Html.Kendo().Grid<PaysmardService.Models.Users>("Users")
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.FirstName).Width(110);
columns.Bound(e => e.LastName).Width(110);
columns.Bound(e => e.Country).Width(110);
columns.Bound(e => e.City).Width(110);
columns.Bound(e => e.Title);
})
.Sortable()
.Pageable()
.Scrollable()
.ClientDetailTemplateId("template")
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Server()
.PageSize(6)
.Read(read => read.Action("Users", "Home"))
)
.Events(events => events.DataBound("dataBound"))
%>
<script id="template" type="text/kendo-tmpl">
<%: Html.Kendo().Grid<PaysmardService.Models.Phones>("Phones")
.Name("grid_#=ID#")
.Columns(columns =>
{
columns.Bound(o => o.PhoneNumber ).Width(100);
columns.Bound(o => o.IsBlocked ).Width(110);
columns.Bound(o => o.IsEnabled);
columns.Bound(o => o.DeviceType ).Width(200);
})
.DataSource(dataSource => dataSource
.Server()
.PageSize(5)
.Read(read => read.Action("Phones", "Home", new { ID = "#=ID#" }))
)
.Pageable()
.Sortable()
.ToClientTemplate()
%>
</script>
<script>
function dataBound() {
this.expandRow(this.tbody.find("tr.k-master-row").first());
}
</script>
</asp:Content>
here is my controller code:
/////////////Phones/////////////
public ActionResult Phones(int id)
{
_context = new DCPaysmardServiceDataContext();
ViewData["Phones"] = _context.Phones.Where(phones => phones.UserFk == id);
return View();
}
/////////////Users/////////////
public ActionResult Users()
{
_context = new DCPaysmardServiceDataContext();
ViewData["Users"] = _context.Users;
return View();
}
public ActionResult Phones(int id)
{
_context = new DCPaysmardServiceDataContext();
ViewData["Phones"] = _context.Phones.Where(phones => phones.UserFk == id);
return View();
}
/////////////Users/////////////
public ActionResult Users()
{
_context = new DCPaysmardServiceDataContext();
ViewData["Users"] = _context.Users;
return View();
}
and the model is being created with the Linq-to-Sql.
I have tried everything .. but I dont get the selection button and the detail.
It would be very nice if you can give me a hand.
Thanks in advance.