or
01.
public
JsonResult CreateWatch([DataSourceRequest] DataSourceRequest request, HomeWatchListItem hw) {
02.
try
{
03.
var result = uow.HomeWatchesRepository.FindBy(w => w.SerialNo == hw.SerialNo).FirstOrDefault();
04.
if
(result !=
null
) {
05.
ModelState.AddModelError(
"SerialNo"
,
"Serial number already exists"
);
06.
}
07.
if
(ModelState.IsValid) {
08.
uow.HomeWatchesRepository.Add(
new
HomeWatch {
09.
HomeServerId = hw.IdHomeServer,
10.
PatientId = hw.IdPatient,
11.
SerialNo = hw.SerialNo
12.
});
13.
uow.Commit();
14.
}
15.
return
Json(
new
[] {hw}.ToDataSourceResult(request, ModelState));
16.
}
17.
catch
(Exception ex) {
18.
//TODO: what to return here
19.
return
Json(
new
DataSourceResult {Errors = ex.Message});
20.
}
21.
}
01.
@(Html.Kendo().ListView<
HomeWatchListItem
>().Name("watchesListView")
02.
.DataSource(ds => {
03.
ds.Read(r => {
04.
r.Action("GetWatches", "Watches").Type(HttpVerbs.Post);
05.
}).Create(c => {
06.
c.Action("CreateWatch", "Watches").Type(HttpVerbs.Post);
07.
}).Update(u => {
08.
u.Action("EditWatch", "Watches").Type(HttpVerbs.Post);
09.
}).Destroy(d => {
10.
d.Action("DeleteWatch", "Watches").Type(HttpVerbs.Post);
11.
})
12.
.Events(e => {
13.
e.Error("alert('a')");
14.
})
15.
.ServerOperation(true)
16.
.PageSize(4)
17.
.Model(m => {
18.
m.Id("Id");
19.
m.Field<
int
>("IdPatient");
20.
m.Field<
int
>("IdHomeServer");
21.
m.Field<
string
>("PatientName");
22.
m.Field<
string
>("HomeServerName");
23.
});
24.
})
25.
.ClientTemplateId("watch-template")
26.
.Editable(e => {
27.
e.TemplateName("edit-watch-template");
28.
})
29.
.TagName("div")
30.
.HtmlAttributes(new { @class = "k-widget k-listview" })
31.
.Pageable()
32.
.Deferred()
33.
)
@(Html.Kendo().Grid((IEnumerable<
TS.Models.ConnectionManagement.ConnectionManagementSystemTelerik
>)Model)
.Name("grid")
.Columns(columns =>
{
columns.Bound(System => System.SystemId);
columns.Bound(System => System.SystemType);
columns.Bound(System => System.SiteId);
columns.Bound(System => System.SiteName);
columns.Bound(System => System.SiteAddress);
columns.Bound(System => System.IsSecured);
})
.Pageable() // Enable paging
.Sortable() // Enable sorting
)
Error: Invalid template:'
<div id="details-container">
<div class="k-widget k-calendar" id="test"></div><script>
jQuery(function(){jQuery("#test").kendoCalendar({});});
' Generated code:'var o,e=kendo.htmlEncode;with(data){o='\n <div id="details-container">\n <div class="k-widget k-calendar" id="test"></div><script>\n\tjQuery(function(){jQuery("';test").kendoCalendar({});});
;o+=;}return o;'
@(Html.Kendo().Window().Name("Details").Title("Customer Details")
.Visible(false).Modal(true).Draggable(true).Width(900).Height(400))
<
script
type
=
"text/x-kendo-template"
id
=
"CopyProjectTemplate"
>
<
div
id
=
"details-container"
>
@(Html.Kendo().Calendar().Name("test"))
</
div
>
</
script
>
$(document).ready(function () {
$("#grdTimelogDetail_btnSaveTemplate_onclick").click(function (e) {
e.preventDefault();
try {
var detailsTemplate = kendo.template($("#CopyProjectTemplate").html());
return false;
}
catch (err) { alert(err); }
});
});