or
@(Html.Kendo().Grid<
UserViewModel
>()
.Name("Grid")
.ToolBar(toolbar => {
toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Sortable()
.Pageable(pager => pager.PageSizes(true))
.Selectable()
.Columns(columns =>
{
columns.Bound(c => c.DisplayName);
columns.Bound(p => p.Attended)
.Title("Attended")
.ClientTemplate("<
input
type
=
'checkbox'
#= Attended ?
checked
=
'checked'
: '' #
class
=
'chkbx'
/>")
.HtmlAttributes(new { style = "text-align: center" }).Width(50);
columns.Bound(c => c.Duration).Width(100);
columns.Command(commands => commands.Destroy()).Width(100).Title("Remove");
})
.DataSource(dataSource => dataSource.Ajax()
.Model(model =>
{
model.Id(p => p.ServiceUserID);
model.Field(p => p.DisplayName).Editable(false);
})
.ServerOperation(false)
.Read(read => read.Action("_GetAttendees", "Activity", new { ViewBag.ActivityID }))
.Create(update => update.Action("_AddAttendees", "Activity"))
.Update(update => update.Action("_UpdateAttendees", "Activity"))
.Destroy(update => update.Action("_RemoveAttendees", "Activity"))
.Batch(true)
.PageSize(20)
)
)
function
AddUser(searchModel) {
$.getJSON(
"/Activity/GetUser"
, searchModel,
function
(data) {
switch
(data.Value) {
case
0:
<snip>
break
;
case
-1:
<snip>
break
;
default
:
var
grid = $(
"#Grid"
).data(
"kendoGrid"
);
var
datasource = grid.dataSource;
var
activityID = @ViewBag.ActivityID;
var
User = { UserID: data.Value, ActivityID: activityID, DisplayName: data.Message, Attended: 0 @ViewBag.Duration };
datasource.insert(User);
break
;
}
return
false
;
});
};
var
homogeneous =
new
kendo.data.HierarchicalDataSource({
transport: {
read: {
url:
'http://localhost:500/api/users/'
,
dataType:
"json"
}
},
schema: {
model: {
id:
"id"
,
hasChildren:
"load_on_demand"
}
}
});
$(
"#tree"
).kendoTreeView({
dataSource: homogeneous,
dataTextField:
"label"
});
[{
"id"
:12345,
"label"
:
"NODE 1"
,
"load_on_demand"
:
true
}]
$(document).ready(
function
() {
$(
"#listView"
).kendoListView({
dataBound:
function
(e) {
var
listView = $(
"#listview"
);
if
(!listView) {
alert(
"listView null"
);
return
;
}
var
listData = listView.data(
"kendoListView"
);
if
(!listData) {
alert(
"listData null"
);
return
;
}
}
});