or
.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
>
@(Html.Kendo().MultiSelectFor(model=>model.RoleList)
.Name("RoleList")
.HtmlAttributes(new { style = "width: 310px;" })
.Placeholder("Select roles...")
.DataTextField("RoleName")
.DataValueField("RoleId")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetClientRolesList", "Client", new { id = ViewContext.RouteData.Values["id"] });
read.Type(HttpVerbs.Post);
})
.ServerFiltering(false);
})
)
[DisplayName("Roles")]
public List<
RoleViewModel
> RoleList
{
get;
set;
}
namespace MyApp.Models
{
public class RoleViewModel
{
public int RoleId
{
get;
set;
}
public string RoleName
{
get;
set;
}
}
}
public ActionResult GetClientRolesList(int id, [DataSourceRequest] DataSourceRequest request)
{
using (var db = new MyAppEntities())
{
var rolesList = (from role in db.webpages_Roles
select new RoleViewModel()
{
RoleId = role.RoleId,
RoleName = role.RoleName
});
return Json(rolesList.ToList());
}
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ClientUser_Update(int id, [DataSourceRequest] DataSourceRequest request, ClientUserViewModel clientUser)
{
if (clientUser != null && ModelState.IsValid)
{
try
{
ClientUserRepository.Update(id,clientUser);
}
catch (Exception ex)
{
ModelState.AddModelError("ClientName", ex.Message);
}
}
return Json(new[] { clientUser }.ToDataSourceResult(request, ModelState));
}
@(Html.Kendo().Grid<
MyApp.Models.ClientUserViewModel
>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(u => u.UserId).Hidden();
columns.Bound(u => u.FirstName).Width(100);
columns.Bound(u => u.LastName).Width(100);
columns.Bound(u => u.UserName).Width(100);
columns.Bound(u => u.RoleList).Hidden();
columns.Bound(u => u.zTimestamp).Hidden();
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ClientUser"))
.Pageable()
.Filterable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:580px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Batch(false)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(u => u.UserId))
.Create(update => update.Action("ClientUser_Create", "Client", new { id = ViewContext.RouteData.Values["id"] }))
.Read(read => read.Action("ClientUser_Read", "Client", new { id = ViewContext.RouteData.Values["id"] }))
.Update(update => update.Action("ClientUser_Update", "Client", new { id = ViewContext.RouteData.Values["id"] }))
.Destroy(update => update.Action("ClientUser_Destroy", "Client", new { id = ViewContext.RouteData.Values["id"] }))
)
)