or
public ActionResult Products_Read([DataSourceRequest]DataSourceRequest request)
{
var products = new NorthwindDataContext().Products;
DataSourceResult result = products.ToDataSourceResult(request);
return Json(result);
}
@(Html.Kendo().Grid(Model.DocumentSearchList).Name("Grid")
.Sortable()
.Filterable()
.Pageable()
.Selectable(selectable => selectable.Mode(Model.Workflow == null ?
GridSelectionMode.Single :
(Model.Workflow.SelectionMode == SelectionMode.Single ? GridSelectionMode.Single : GridSelectionMode.Multiple)))
.Columns(col =>
{
col.Bound(model => model.DocumentTypeName).Title("Type");
col.Bound(model => model.DocumentSubtypeName).Title("SubType");
col.Bound(model => model.DocumentStatusName).Title("Status");
col.Bound(model => model.ShortTitle).Title("Doc Title");
col.Bound(model => model.JurisdictionName).Title("Jurisdiction");
col.Bound(model => model.TopicsCount).Title("Topics");
col.Bound(model => model.WorkOrdersCount).Title("Work Orders");
col.Bound(model => model.WOSubmittedUserFullName).Title("Submitted By");
col.Bound(model => model.WorkOrderSubmittedDate).Title("On").Format("{0:MM/dd/yyyy}");
col.Bound(model => model.CreatedUserFullName).Title("Created By");
col.Bound(model => model.CreatedDate).Title("On").Format("{0:MM/dd/yyyy}");
col.Bound(model => model.UpdatedUserFullName).Title("Updated By");
col.Bound(model => model.LastUpdatedDate).Title("On").Format("{0:MM/dd/yyyy}");
})
.DataSource(dataSource => dataSource.Ajax()
.Model(model => model.Id(p => p.DocumentId))
)
.Events(e => e.Change("selection_change")))
$(document).ready(
function
() {
var
src =
new
kendo.data.DataSource({
transport: {
read: {
url:
"Handlers/TaskHandler.ashx"
,
dataType:
"json"
,
type:
"GET"
,
},
update: {
url:
"Handlers/TaskHandler.ashx"
,
dataType:
"json"
,
type:
"PUT"
,
},
destroy: {
url:
"Handlers/TaskHandler.ashx"
,
dataType:
"json"
,
type:
"DELETE"
,
},
create: {
url:
"Handlers/TaskHandler.ashx"
,
dataType:
"json"
,
type:
"POST"
,
},
parameterMap:
function
(options, operation) {
if
(operation !==
"read"
&& options.models) {
return
{ tasks: kendo.stringify(options.models) };
}
}
},
batch:
true
,
schema: {
model: {
id:
"Id"
,
fields: {
Id: { editable:
false
, nullable:
true
},
Description: { type:
"string"
, editable:
true
},
IsComplete: { type:
"boolean"
, editable:
true
},
Priority: { type:
"number"
, editable:
true
},
CreatedOn: { type:
"date"
, editable:
false
, defaultValue:
new
Date() }
}
}
},
});
$(
'#task-data'
).kendoGrid({
toolbar: [
"create"
,
"save"
,
"cancel"
],
columns: [
{
field:
"Id"
,
width: 44,
title:
"ID"
}, {
field:
"Description"
,
}, {
field:
"Priority"
,
width: 110,
title:
"Prio"
}, {
field:
"IsComplete"
,
width: 90,
title:
"Complete"
} , {
field:
"CreatedOn"
,
width: 120,
title:
"Created"
,
format:
"{0:yyyy-MM-dd}"
}, {
command: [
"destroy"
], title:
""
, width: 120
}
],
pageable: {
pageSize: 5
},
scrollable:
true
,
editable:
true
,
navigatable:
true
,
sortable:
true
,
dataSource: src
//dataSource: {
// transport: {
// read: {
// url: "Handlers/TaskHandler.ashx",
// dataType: "json",
// type: "GET",
// },
// update: {
// url: "Handlers/TaskHandler.ashx",
// dataType: "json",
// type: "PUT",
// },
// destroy: {
// url: "Handlers/TaskHandler.ashx",
// dataType: "json",
// type: "DELETE",
// },
// create: {
// url: "Handlers/TaskHandler.ashx",
// dataType: "json",
// type: "POST",
// },
// parameterMap: function (options, operation) {
// if (operation !== "read" && options.models) {
// return { tasks: kendo.stringify(options.models) };
// }
// }
// },
// batch: true,
// schema: {
// model: {
// id: "Id",
// fields: {
// Id: { editable: false, nullable: true },
// Description: { type: "string", editable: true },
// IsComplete: { type: "boolean", editable: true },
// Priority: { type: "number", editable: true },
// CreatedOn: { type: "date", editable: false, defaultValue: new Date() }
// }
// }
// },
//}
});
});