or
@(
Html.Kendo().Grid<.Models.ConnectionView>()
.Name("ConnectionView")
.Columns(columns =>
{
columns.ForeignKey(c => c.ConnId, Model.All, "Value", "Text").Title("Restriction");
columns.Bound(c => c.MaxEnrollment);
columns.Command(command =>
{
command.Custom("move-up").Text("u").Click("OnMoveUp");//, "Home", new {Area="Sessions",id="#=Id#" });
command.Custom("move-down").Text("d").Click("OnMoveDown");//, "Home", new { Area = "Sessions", id = "#=Id#" });
command.Edit();
command.Destroy();
});
})
.Pageable(page =>
{
page.Enabled(true);
page.Input(false);
page.Numeric(false);
page.PreviousNext(true);
page.Messages(message => message.Empty("There are no records to show. Click the Add button to create a row"));
})
.ToolBar(toolbar => toolbar.Create().Text("Add"))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.Events(events =>
{
events.Error("error_handler");
})
.Model(model =>
{
model.Id(m => m.Id);
model.Field(m => m.ConnId).DefaultValue(int.Parse(Model.All.First().Value));
})
.Create(update => update.Action("ConnectionView_Create", "Home"))
.Read(read => read.Action("ConnectionView_Read", "Home"))
.Update(update => update.Action("ConnectionView_Update", "Home"))
.Destroy(update => update.Action("ConnectionView_Destroy", "Home"))
)
public ActionResult RestrictionConnectionView_Create([DataSourceRequest] DataSourceRequest request, RestrictionConnectionView connector)
{
var newConn = new OrientationSession_RestrictionConnector();
if (ModelState.IsValid)
{
var restrictionRepo = new EFRepository<
Restriction
>(_uow);
var restriction = restrictionRepo.GetByKey(connector.RestrictionId);
var repo = new EFRepository<
Conn
>(_uow);
var session = repo.WhereIncluding(w => w.Id == _WorkingSessionId, i => i.RestrictionConnectors).FirstOrDefault();
if (session != null && restriction != null)
{
newConn.OrientationSessionId = _WorkingSessionId;
newConn.Restriction = restriction;
newConn.MaxEnrollment = connector.MaxEnrollment;
newConn.CreatedBy = User.Identity.Name;
newConn.SequenceNumber = session.RestrictionConnectors == null || session.RestrictionConnectors.Count == 0 ? 1 : session.RestrictionConnectors.Max(m => m.SequenceNumber) + 1;
session.RestrictionConnectors.Add(newConn);
repo.Update(session);
_uow.Commit();
ResetSessionVars();
}
}
connector.Id = newConn.Id;
return Json(new[] { connector }.ToDataSourceResult(request, ModelState));
}
function
viewInit(e) {
e.view.element.find(
"#listView"
).kendoMobileListView({
dataSource: [
{ id: 1, text:
"foo"
},
{ id: 2, text:
"bar"
}
],
template:
"id: #: id# with text: #: text#"
,
filterable: [
{ ignoreCase:
true
, field:
"text"
},
{ field:
"id"
}
]
});
}