or
@using MvcMenuPopup.Models
@{
ViewBag.Title = "People";
}
<
h2
>Some People</
h2
>
@(Html
.Kendo()
.Grid<
Person
>()
.Name("peopleGrid")
.Columns(columns =>
{
columns.Template(t => { }).ClientTemplate(
Html
.Kendo()
.Menu()
.Name("themenu#=PersonId#")
.Items(menu => menu.Add().Text("::").Items(sub =>
{
sub.Add().Text("Do this thing");
sub.Add().Text("Do that thing");
}))
.Orientation(MenuOrientation.Vertical)
.HighlightPath(true)
.OpenOnClick(false)
.ToClientTemplate()
.ToHtmlString()
)
.HtmlAttributes(new { @class = "navigationColumn", style = "overflow: visible;" })
.Width(50);
columns.Bound(t => t.Birthday);
columns.Bound(t => t.FirstName);
columns.Bound(t => t.Surname);
})
.DataSource(binding => binding.Ajax().Read("PeopleAjax", "Home")))
namespace
MvcMenuPopup.Models
{
using
System;
public
class
Person
{
public
long
PersonId {
get
;
set
; }
public
DateTime Birthday {
get
;
set
; }
public
string
FirstName {
get
;
set
; }
public
string
Surname {
get
;
set
; }
}
}
namespace
MvcMenuPopup.Controllers
{
using
System;
using
System.Linq;
using
System.Web.Mvc;
using
Kendo.Mvc.Extensions;
using
Kendo.Mvc.UI;
using
MvcMenuPopup.Models;
public
class
HomeController : Controller
{
public
ActionResult Index()
{
return
this
.View();
}
public
ActionResult About(
string
firstName)
{
return
this
.View((
object
)firstName);
}
public
JsonResult PeopleAjax([DataSourceRequest]DataSourceRequest request)
{
DataSourceResult result = GetPeople().OrderByDescending(train => train.Birthday).ToDataSourceResult(request);
return
this
.Json(result);
}
private
static
IQueryable<Person> GetPeople()
{
var birthdays = Enumerable.Range(1, 12).Select(month =>
new
DateTime(1980, month, 1)).ToList();
return
birthdays.Select((date, index) =>
new
Person
{
PersonId = index,
Birthday = date,
FirstName =
"Bill"
+ index,
Surname =
"Smith"
+ index
}).AsQueryable();
}
}
}
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
data: createRandomData(50),
pageSize: 10
},
selectable: true,
groupable: true,
sortable: true,
pageable: {
refresh: true,
pageSizes: true
},
columns: [{
field: "FirstName",
width: 90,
title: "First Name"},
{
field: "LastName",
width: 90,
title: "Last Name"},
{
width: 100,
field: "City"},
{
field: "Title"},
{
field: "BirthDate",
title: "Birth Date",
template: '#= kendo.toString(BirthDate,"dd MMMM yyyy") #'},
{
width: 50,
field: "Age"}
]
});
});​
var
people = [
{ firstName:
"Hasibul"
, lastName:
"Haque"
, email:
"hasibul@yahoo.com"
}
];
$(
'#grid'
).kendoGrid({
scrollable:
true
,
sortable:
true
,
pageable:
true
,
selectable:
"row"
,
filterable:
true
, dataSource: { data: people, pageSize: 10 }
, columns:
[
{ field:
"firstName"
, title:
"First Name"
}
, { field:
"lastName"
, title:
"Last Name"
}
, { field:
"email"
, title:
"email"
}
, {
field:
"action"
, title:
"Action"
,
template:
"I want to put action linke here by using field value(firstName)"
}
]
});
column.Template(c => @Html.ActionLink(c.Description,
"foo"
,
new
{ id = c.prop, })
<body>
@Html.Kendo().Calendar().Name(
"calendarstart"
).Value(DateTime.Now)
<button id=
"save"
>Set date</button>
<script>
$(document).ready(
function
() {
$(
"#save"
).click(
function
() {
var
startDate = $(
"#calendarstart"
).data(
"kendoCalendar"
);
$.post(
"/Home/Index"
, { StartDate: startDate.value() });
});
});
</script>
</body>
The issue i see is that their is no tight binding like what you have on MVC view model binding.
Jay