or
public ActionResult Section()
{ return View(); } public ActionResult EditingPopup_Read([DataSourceRequest] DataSourceRequest request) { return Json(db.Sections.Where( s=>s.IsPublished == true).ToList().ToDataSourceResult(request)); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult EditingPopup_Create([DataSourceRequest] DataSourceRequest request, Section section) { if (section != null && ModelState.IsValid) { db.Sections.Add(section); db.SaveChanges(); } return Json(new[] { section }.ToDataSourceResult(request, ModelState)); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult EditingPopup_Update([DataSourceRequest] DataSourceRequest request, Section section) { if (section != null && ModelState.IsValid) { var target = db.Sections.FirstOrDefault( s => s.SectionID == section.SectionID); if (target != null) { target.Name = section.Name; target.Description = section.Description; db.Entry<Section>(section).State = System.Data.EntityState.Modified; db.SaveChanges(); } } return Json(ModelState.ToDataSourceResult()); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult EditingPopup_Destroy([DataSourceRequest] DataSourceRequest request, Section section) { if (section != null && ModelState.IsValid) { var target = db.Sections.FirstOrDefault(s => s.SectionID == section.SectionID); if (target != null) { target.IsPublished = false; db.Entry<Section>(section).State = System.Data.EntityState.Modified; db.SaveChanges(); } } return Json(ModelState.ToDataSourceResult()); }
@(Html.Kendo().Grid<MVC4Kendo.Models.Section>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.Name);
columns.Bound(p => p.Description).Width(100);
columns.Bound(p => p.IsPublished).Width(100);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.SectionID))
.Create(update => update.Action("EditingPopup_Create", "Grid"))
.Read(read => read.Action("EditingPopup_Read", "Grid"))
.Update(update => update.Action("EditingPopup_Update", "Grid"))
.Destroy(update => update.Action("EditingPopup_Destroy", "Grid"))
)
)
<script type="text/javascript">
function error_handler(e) {
if (e.errors) {
var message = "Errors:\n";
$.each(e.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n";
});
}
});
alert(message);
}
}
</script>
var cbx = $("select").data("kendoComboBox")
cbx.select(2);01.$("#hum-log").kendoSparkline({02. type: "area",03. data: [04. 71, 70, 69, 68, 65, 60, 55, 55, 50, 52,05. 73, 72, 72, 71, 68, 63, 57, 58, 53, 55,06. 63, 59, 61, 64, 58, 53, 48, 48, 45, 45,07. 63, 64, 63, 67, 58, 56, 53, 59, 51, 5408. ],09. height: 50,10. tooltip: {11. format: "{0} %"12. }13. });{"Data":[],"Total":4,"AggregateResults":null,"Errors":null}@(Html.Kendo().ComboBox() .Name("productComboBox") //The name of the combobox is mandatory. It specifies the "id" attribute of the widget. .DataTextField("ALLERGYTYPE") //Specifies which property of the Product to be used by the combobox as a text. .DataValueField("ID") //Specifies which property of the Product to be used by the combobox as a value.// .Filter(FilterType.Contains) .Placeholder("ALLERGYTYPE") .DataSource(source => { source.Read(read => { read.Action("GetProducts", "AllergiesData"); //Set the Action and Controller name }) .ServerFiltering(true); //If true the DataSource will not filter the data on the client. })public JsonResult GetProducts(){ PHRDevEntities patient = new PHRDevEntities(); return Json(patient.PR_PATIENTALLERGY, JsonRequestBehavior.AllowGet);}public ActionResult Get([DataSourceRequest]DataSourceRequest request) { return Json(DataAccess.Get(request), JsonRequestBehavior.AllowGet); } public ActionResult CreateSingle([DataSourceRequest]DataSourceRequest request, TEntity itemNew) { return Json(DataAccess.Create(request, itemNew.ToArrayFromObject(), false, ModelState), JsonRequestBehavior.AllowGet); }public ActionResult Create([DataSourceRequest]DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<TEntity> itemsNew) { return Json(DataAccess.Create(request, itemsNew, true, ModelState)); } public ActionResult UpdateSingle([DataSourceRequest]DataSourceRequest request, TEntity itemUpdated) { return Json(DataAccess.Update(request, itemUpdated.ToArrayFromObject(), false, ModelState), JsonRequestBehavior.AllowGet); } public ActionResult DestroySingle([DataSourceRequest]DataSourceRequest request, TEntity itemToDelete) { return Json(DataAccess.Destroy(request, itemToDelete.ToArrayFromObject(), false, ModelState), JsonRequestBehavior.AllowGet); }@model KendoUIMvcApplication1.DATA.PR_PATIENTALLERGY <strong>PR_PATIENTALLERGY</strong> <br /> <table width="100%" cellspacing="5" style="margin:20px"> <tr> <td width="10%">@Html.LabelFor(model => model.PATIENTID)</td> <td width="40%">@Html.EditorFor(model => model.PATIENTID) @Html.ValidationMessageFor(model => model.PATIENTID)</td> <td width="10%">@Html.LabelFor(model => model.DOCTOR)</td> <td width="40%" >@(Html.Kendo().ComboBox() .Name("productComboBox") //The name of the combobox is mandatory. It specifies the "id" attribute of the widget. .DataTextField("ALLERGYTYPE") //Specifies which property of the Product to be used by the combobox as a text. .DataValueField("ID") //Specifies which property of the Product to be used by the combobox as a value. // .Filter(FilterType.Contains) .Placeholder("ALLERGYTYPE") .DataSource(source => { source.Read(read => { read.Action("GetProducts", "AllergiesData"); //Set the Action and Controller name }) .ServerFiltering(true); //If true the DataSource will not filter the data on the client. }) //.SelectedIndex(0) //Select first item. ) @Html.ValidationMessageFor(model => model.DOCTOR)</td> </tr> <tr> <td width="10%">@Html.LabelFor(model => model.ISACTIVE)</td> <td width="40%" >@Html.EditorFor(model => model.ISACTIVE) @Html.ValidationMessageFor(model => model.ISACTIVE)</td> </tr> </table>Html.Kendo().Grid<AdminReport>() .Name("AdminReportList").Columns(c => {c.Bound(r => r.Name).Title("Report Name").Width(50); c.Bound(r => r.Id).Title(action).Width(230).Sortable(false).Filterable(false)}).Pageable(p => p.PreviousNext(true)).Sortable().Filterable() .Events(e => e.DataBound("onRowBound")) .DataSource(d => d .Ajax() .Model(m => m.Id(r => r.Id)) .Read(read => read.Action("_ListAllReports", "AdminReports")) .Events(e => e.Error("OnError"))).Render();function onRowBound(e) { if ((e.dataItem.SomeProperty === true)) { //Some code... }}