or
<
div
id
=
"grid"
data-role
=
"grid"
data-bind
=
"source: gridDataSource"
data-editable
=
"inline"
data-columns='[
{ "command": ["edit", "destroy"], "title": " ", "width": "120px" },
{ "field": "title", "width": "100px", "editor": "titleEditor"},
{ "field": "year", "width": "100px" }
]'>
</
div
>
function titleEditor(container, options) {
var inputField = $('<
input
data-text-field
=
"title"
data-value-field
=
"title"
data-bind
=
"value:' + options.field + '"
/>');
var button = $('<
span
unselectable
=
"on"
class
=
"k-icon k-i-search"
>select</
span
>');
button.click(function(e) {
lookupdialog.dialog({
});
});
inputField.after(button);
inputField.appendTo(container);
};
filter: [
{ field:
"SYMBOL"
, operator:
"eq"
, value:
"NLP"
},
{ field:
"EFFECTIVE_DATE"
, operator:
"eq"
, value:
"\/Date(1065657600000)\/"
}
],<script>
$(document).ready(
function
() {
var
grid = $(
"#grid"
).kendoGrid({
dataSource: {
type:
"odata"
,
transport: {
read:
"http://someURL/Data.svc/Policies"
,
// dataType: "json",
},
filter: [{
field:
"SYMBOL"
,
operator:
"eq"
,
value:
"NLP"
}, {
field:
"EFFECTIVE_DATE"
,
operator:
"eq"
,
value:
"\/Date(1065657600000)\/"
}],
schema: {
model: {
fields: {
SYMBOL: {
type:
"string"
},
FIRM_NAME: {
type:
"string"
},
EFFECTIVE_DATE: {
type:
"date"
},
PolicyStatusID: {
type:
"string"
},
}
}
},
pageSize: 20,
serverPaging:
true
,
serverFiltering:
true
,
serverSorting:
true
},
height: 350,
filterable:
true
,
sortable:
true
,
pageable:
true
,
columns: [{
field:
"FIRM_NAME"
,
}, {
format:
"{0:MM/dd/yyyy}"
,
field:
"EFFECTIVE_DATE"
,
title:
"EFFECTIVE_DATE"
,
// template: '#= kendo.toString(EFFECTIVE_DATE, "MM/dd/yyyy") #'
}, {
field:
"PolicyStatusID"
,
}, {
field:
"SYMBOL"
,
}, ]
});
});
</script>
$(
'#toggleMenu'
).click(
function
() {
if
($(
'#menuPane'
).is(
':visible'
)) {
$(
"#menuPane"
).kendoAnimate({ hide:
true
, effects:
"slideOut:left"
});
}
else
{
$(
"#menuPane"
).kendoAnimate({ show:
true
, effects:
"slideIn:left"
});
}
});
{"data":[{"Key":"Azure Getting Started","HasSubgroups":false,"Items":[{"Name":"Azure Getting Started","Price":540.00,"Self":"api/books/3","Id":3},{"Name":"Azure Getting Started","Price":150.00,"Self":"api/books/5","Id":5}],"Aggregates":{"Price":{"Sum":690.00,"Min":150.00,"Max":540.00},"Name":{"Count":2}},"Subgroups":[]},{"Key":"Entity FrameWork","HasSubgroups":false,"Items":[{"Name":"Entity FrameWork","Price":350.00,"Self":"api/books/2","Id":2}],"Aggregates":{"Price":{"Sum":350.00,"Min":350.00,"Max":350.00},"Name":{"Count":1}},"Subgroups":[]}],"total":5,"aggregates":{"Price":{"Sum":1810.00,"Min":150.00,"Max":550.00},"Name":{"Count":5}}}
var grid = $("#ordersGrid").kendoGrid({
// specify the columns on the grid
toolbar: ["create"],
columns: [
{ field: "Name", title: "Name", width: "100px" },
{ field: "Price", title: "Price", width: "100px", aggregates: ["Min", "Max", "Sum"], footerTemplate: "Sum:#=Sum# Min:#=Min# Max:#=Max#", groupFooterTemplate: "Sum: " },
{ command: ["edit", "destroy"], title: " ", width: "210px" }
],
// the datasource for the grid
dataSource: new kendo.data.DataSource({
// the transport tells the datasource what endpoints
// to use for CRUD actions
transport: {
read: {
url: "/apibook/readget",
type: "POST"
},
update: {
url: "/apibook/update",
type: "POST"
},
destroy: {
url: "/apibook/destroy",
type: "POST"
},
create: {
url: "/apibook/create",
type: "POST"
},
parameterMap: function (options, operation) {
if (operation != "read") {
var result = {};
for (var i = 0; i < options.models.length; i++) {
var book = options.models[i];
debugger;
for (var member in book) {
result["books[" + i + "]." + member] = book[member];
}
}
return result;
}
if (operation == "read") {
var result = {};
result["take"] = options.take;
result["skip"] = options.skip;
result["page"] = options.page;
if (options.sort != null) {
for (var i = 0; i < options.sort.length; i++) {
result["sort[" + i + "]." + "dir"] = options.sort[i].dir;
result["sort[" + i + "]." + "field"] = options.sort[i].field;
}
}
if (options.aggregate != null) {
var aggregates = "";
debugger;
for (var i = 0; i < options.aggregate.length; i++) {
if (aggregates == "") {
aggregates = options.aggregate[i].field + "-" + options.aggregate[i].aggregate;
}
else
aggregates += "~" + options.aggregate[i].field + "-" + options.aggregate[i].aggregate;
}
result["aggregates"] = aggregates;
//for (var i = 0; i < options.aggregate.length; i++) {
// result["aggregate[" + i + "]." + "aggregate"] = options.aggregate[i].aggregate;
// result["aggregate[" + i + "]." + "field"] = options.aggregate[i].field;
//}
}
result["groupBy"] = "Name-asc";
if (options.filter != null) {
var filter = options.filter;
if (filter.filters != null) {
for (var i = 0; i < filter.filters.length; i++) {
result["filter[" + i + "].field"] = filter.filters[i].field;
result["filter[" + i + "].op"] = filter.filters[i].operator;
result["filter[" + i + "].value"] = filter.filters[i].value;
}
}
}
return result;
}
}
},
group: {
field: "Name",
aggregates: [
{ field: "Price", aggregate: "sum" },
{ field: "Price", aggregate: "min" },
{ field: "Price", aggregate: "max" },
]
},
aggregate: [
{ field: "Price", aggregate: "sum" },
{ field: "Price", aggregate: "min" },
{ field: "Price", aggregate: "max" },
{ field: "Name", aggregate: "count" }],
// the schema defines the schema of the JSON coming
// back from the server so the datasource can parse it
schema: {
// the array of repeating data elements (employees)
data: function (response) {
debugger;
//return response.Data.Items;
return response.data;
},
groups: function (response) {
debugger;
//return response.Data.Items;
return response.data;
},
aggregates: function (response) {
if (response.aggregates != null)
return response.aggregates;
else
return {};
},
model: {
id: "Id",
fields: {
// specify all the model fields, along with validation rules and whether or
// not they can be edited or nulled out.
Id: { editable: false, nullable: true },
Name: { editable: true },
Price: { editable: true, nullable: false, validation: { required: true } },
}
},
// the total count of records in the whole dataset. used
// for paging.
total: "Count",
},
// the number of records to show per page
pageSize: 3,
// do paging on the server
serverPaging: true,
// do sorting on the server
serverSorting: true,
serverAggregates: true,
serverGrouping:true,
batch: true
}),
// paging is enabled in the grid
pageable: true,
// editing happens inline, one row at a time.
editable: "popup",
selectable: true,
// sort by multiple columns
sortable: {
mode: "multiple"
},
change: function (e) {
// get the current item selected in the grid
var employee = this.dataSource.getByUid(this.select().data("uid"));
// write out the employee id
console.log(employee.id);
}
}).data("kendoGrid");
<
link
rel
=
"shortcut icon"
href
=
"@Url.Content("
~/Content/images/favicon.gif")"
type
=
"image/x-icon"
/>
<
link
href
=
"@Url.Content("
~/Content/Site.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
link
href
=
"@Url.Content("
~/Content/css/global.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
link
href
=
"@Url.Content("
~/Content/kendo.dataviz.min.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
link
href
=
"@Url.Content("
~/Content/kendo.common.min.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
link
href
=
"@Url.Content("
~/Content/kendo.default.min.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
script
src
=
"@Url.Content("
~/Scripts/jquery.min.js")"
type
=
"text/javascript"
></
script
>
<
script
src
=
"@Url.Content("
~/Scripts/kendo.dataviz.min.js")"></
script
>
<
script
src
=
"@Url.Content("
~/Scripts/kendo.web.min.js")"
type
=
"text/javascript"
></
script
>
<
script
src
=
"@Url.Content("
~/Scripts/kendo.aspnetmvc.min.js")"
type
=
"text/javascript"
></
script
>
<
script
src
=
"@Url.Content("
~/Scripts/corners.js")"
type
=
"text/javascript"
></
script
>
<
script
src
=
"@Url.Content("
~/Scripts/menu.js")"
type
=
"text/javascript"
></
script
>
<
script
src
=
"@Url.Content("
~/Scripts/jquery.validate.min.js")"
type
=
"text/javascript"
></
script
>
<
script
src
=
"@Url.Content("
~/Scripts/jquery.validate.unobtrusive.min.js")"
type
=
"text/javascript"
></
script
>
@(Html.Kendo().Grid<
WANDA.ViewLookupStaffTag
>()
.Name("StaffTagGrid")
.BindTo((IEnumerable<
WANDA.ViewLookupStaffTag
>)ViewBag.StaffTag)
.Columns(columns =>
{
columns.Bound(p => p.StaffTagDesc).Title("Description");
columns.Bound(p => p.StaffTagCategoryDesc).GroupHeaderTemplate(
@<
text
>
Tag Category : @item.Key
</
text
>);
columns.Bound(p => p.StaffTagStatus).EditorTemplateName("StaffTagStatusDDL").Width(140).Title("Status");
columns.Command(command => { command.Edit(); }).Width(200);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(Kendo.Mvc.UI.GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Server()
.Group(groups => groups.Add(p => p.StaffTagCategoryDesc))
.Sort(sort => sort.Add(p=>p.StaffTagDesc))
.Model(model => model.Id(p => p.StaffTagID))
.Create(create => create.Action("StaffTag_Create", "Setup"))
.Read(read => read.Action("StaffTag", "Setup"))
.Update(update => update.Action("StaffTag_Update", "Setup"))
.Destroy(delete => delete.Action("StaffTag_Destroy", "Setup")))
.RowAction(
row =>
{
if (row.DataItem.StaffTagStatus == "Inactive")
{
row.HtmlAttributes["class"] = "inactive-status";
}
})
.Pageable(pager => pager.PageSizes(true))
.Sortable()
.Filterable()
.DataSource(data => data.Server().PageSize(100)))