or
@(Html.Kendo().Grid<BillHeader>()
.Name(
"BillHeaders"
)
.Columns(columns =>
{
columns.Bound(h => h.BillHeaderId);
columns.Bound(h => h.Category);
columns.Bound(h => h.Description);
columns.Bound(h => h.Amount);
})
.Pageable()
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Multiple)
.Type(GridSelectionType.Row))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(6)
.Events(events => events.Error(
"error_handler"
))
.Read(read => read.Action(
"BillHeaders_Read"
,
"Bill"
))
)
.Events(events => events.DataBound(
"dataBound"
))
.ClientDetailTemplateId(
"BillDetails"
)
)
<script id=
"BillDetails"
type=
"text/kendo-tmpl"
>
@(Html.Kendo().Grid<BillDetail>()
.Name(
"BillDetails_#=BillHeaderId#"
)
.Columns(columns =>
{
columns.Bound(d => d.BillHeaderId).Width(50);
columns.Bound(d => d.BillDetailId).Width(70);
columns.Bound(d => d.Category).Width(70);
columns.Bound(d => d.Description).Width(150);
columns.Bound(d => d.Amount).Width(80);
columns.Command(command =>
{
command.Edit();
command.Destroy();
}).Width(75);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Model(model =>
{
model.Id(d => d.BillDetailId);
model.Field(d => d.BillDetailId).Editable(
false
);
})
.Events(events => events.Error(
"error_handler"
))
.Read(read => read.Action(
"BillDetails_Read"
,
"Bill"
,
new
{ billHeaderId =
"#=BillHeaderId#"
}))
.Update(update => update.Action(
"BillDetail_Update"
,
"Bill"
))
.Create(create => create.Action(
"BillDetail_Create"
,
"Bill"
,
new
{ billHeaderId =
"#=BillHeaderId#"
}))
.Destroy(destroy => destroy.Action(
"BillDetail_Destroy"
,
"Bill"
)))
.Pageable()
.ToolBar(tools => tools.Create())
.ToClientTemplate()
)
</script>
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult BillDetail_Create(BillDetail billDetail,
int
billHeaderId)
{
if
(billHeaderId == 0)
{
ModelState.AddModelError(
"billHeaderID"
,
"add bill header first"
);
}
if
(billDetail !=
null
&& ModelState.IsValid)
{
var target =
new
BillDetail
{
Category = billDetail.Category,
Description = billDetail.Description,
Amount = billDetail.Amount,
BillHeaderId = billHeaderId,
BillDetailId = SessionBillDetails.Max(d => d.BillDetailId) + 1
};
//Get next Id in sequence
billDetail.BillDetailId = target.BillDetailId;
SessionBillDetails.Add(target);
}
return
Json(
new
[] { billDetail }.ToDataSourceResult(
new
DataSourceRequest(), ModelState));
}
.DataSource(dataSource=>dataSource
.Ajax()
.PageSize(20)
.Model(m=>
{
m.Id(p => p.LogID);
})
.Read(read=>read.Action(
"GetCRISList"
,
"NonDALoads"
)
.Data(
"srchLoad"
)
)
)
.Pageable(p=>p.Refresh(
true
))
.Sortable()
.Filterable()
<script type=
"text/javascript"
>
var
srch = 28;
function
selectionChange() {
var
dropdownlist = $(
"#loadDDL"
).data(
"kendoDropDownList"
);
var
dataItem = dropdownlist.dataItem();
srch = dataItem.LoadID;
//refresh Grid
//$("#Grid").data("kendoGrid").dataSource.read();
$(
'#Grid'
).data().kendoGrid.dataSource.page(1);
}
function
srchLoad() {
return
{
ID: srch
};
}
</script>
$(
'#BookingGrid'
).data().kendoScheduler.resources[0].dataSource.read()
function _LayoutOnLoad()
{
$(function ()
{
$("#MainMenu").kendoTreeView({
select: OnMainMenuSelect
})
});
}
function OnMainMenuSelect(e)
{
alert("Selecting: " + e.node.textContent);
}
$(function () {
var dataSource = new kendo.data.HierarchicalDataSource({
type: "odata",
transport: {
read: {
// See http://www.odata.org/documentation/odata-v2-documentation/uri-conventions/ for OData URI conventions
// OData: ~/api/Users?$inlinecount=allpages&top=2
// OData: ~/api/Users?$inlinecount=allpages - includes odata.count
// OData: inline filtering: ~/api/Users?$filter=USERNAME eq 'asgro'
// to include hierarchical data, use the OData /api/UserGroups?$expand=USER
// To reduce the payload sice, the query ~/api/UserGroups will only include the USERGROUP entities, and not any navigation property content
url: "/api/UserGroups?$expand=USERS",
dataType: "json" // the default result type is JSONP, but WebAPI does not support JSONP
},
parameterMap: function (options, type) {
// this is optional - if we need to remove any parameters (due to partial OData support in WebAPI
var parameterMap = kendo.data.transports.odata.parameterMap(options);
//delete parameterMap.$inlinecount; // remove inlinecount parameter
//delete parameterMap.$format; // remove format parameter
return parameterMap;
}
},
schema: {
data: function (data) {
return data.value;
}
,
total: function (data) {
console.log("count: " + data["odata.count"]);
return data["odata.count"];
},
model: {
fields: {
ID: { type: "string" },
NETWORKID: { type: "string" },
GROUPNAME: { type: "string" },
DESCRIPTION: { type: "string" },
DATECREATED: { type: "date" },
DATEMODIFIED: { type: "date" },
//ROLESSTRING: { type: "string" },
SUBSCRIPTIONSTRING: { type: "string" }
}
}
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true,
detailTemplate: kendo.template($("#template").html()),
detailInit: function(e) {
console.log('detailInit');
// detailInit,
},
dataBound: function () {
this.expandRow(this.tbody.find("tr.k-master-row").first());
}
});
<
body
>
<
div
>
User Groups:
<
div
id
=
"grid"
></
div
>
<
script
type
=
"text/x-kendo-template"
id
=
"template"
>
<
div
class
=
"tabstrip"
>
<
ul
>
<
li
class
=
"k-state-active"
>
Users
</
li
>
</
ul
>
<
div
>
<
div
class
=
'user-details'
>
<
ul
>
<
li
><
label
>User Name:</
label
>#= USERS.USERNAME #</
li
>
<
li
><
label
>First Name:</
label
>#= USERS.FIRSTNAME #</
li
>
<
li
><
label
>Last Name:</
label
>#= USERS.LASTNAME #</
li
>
</
ul
>
</
div
>
</
div
>
</
div
>
</
script
>
</
div
>
</
body
>