or
@model IEnumerable<
PASS.ViewModels.Proposals.IndexViewModel
>
@{
ViewBag.Title = "My Proposals";
}
<
h2
>My Proposals</
h2
>
<
br
/>
<
p
>@Html.ActionLink("Create New Proposal", "Create", null, new { @class="link-button" })</
p
>
@(Html.Kendo().Grid(Model)
.Name("Proposals")
.Columns(columns =>
{
columns.Bound(m => m.ID).Title("Proposal ID");
columns.Bound(m => m.Title).ClientTemplate("<
a
href
=
'" + Url.Action("Update", "Proposals") + "/#= ID #'
>" + "#= Title #" + "</
a
>");
columns.Bound(m => m.ProposalType).Title("Proposal Type");
columns.Bound(m => m.PI);
columns.Bound(m => m.User_Facility_ID).Title("User Facility");
})
.Sortable()
.ClientDetailTemplateId("template")
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(m => m.ID))
.Read(read => read.Action("Index", "Proposals"))
))
<
script
id
=
"template"
type
=
"text/kendo-tmpl"
>
@(Html.Kendo().Grid<
PASS.ViewModels.Proposals.TimeRequestsViewModel
>()
.Name("TimeRequests_#=ID#")
.Columns(columns =>
{
columns.Bound(m => m.Cycle);
columns.Bound(m => m.Status_Description).Title("Status");
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetTimeRequests", "Proposals", new { proposalID = "#=ID#" }))
)
.Sortable()
.ToClientTemplate()
)
</
script
>
public
ActionResult Index()
{
int
user_id = Convert.ToInt32(((Claim)((ClaimsIdentity)Thread.CurrentPrincipal.Identity).FindFirst(a => a.Type.Equals(
"UserID"
))).Value);
using
(var context =
new
PASSEntities())
{
var vm = (from a
in
context.Proposals
join b
in
context.Proposal_Minions on a.ID equals b.Proposal_ID into j
from c
in
j.DefaultIfEmpty()
where (a.PI_User_ID == user_id || a.Creator_User_ID == user_id || (c.User_ID == user_id && c.Can_Read))
select
new
IndexViewModel()
{
ID = a.ID,
Title = a.Title,
ProposalType = a.Proposal_Types.Description,
PI_User_ID = a.PI_User_ID,
PI = (from d
in
context.Pools
join e
in
context.Users on d.ID equals e.Pool_ID
where e.ID == a.PI_User_ID
select d.First_Name +
" "
+ d.Last_Name).FirstOrDefault(),
User_Facility_ID = a.User_Facility_ID
}).Distinct().OrderByDescending(a => a.ID).ToList();
return
View(vm);
}
}
public
ActionResult GetTimeRequests(
int
proposalID, [DataSourceRequest]DataSourceRequest request)
{
using
(var context =
new
PASSEntities())
{
var vm = (from a
in
context.Beamtime_Requests.ToList()
where a.Proposal_ID == proposalID
select
new
TimeRequestsViewModel()
{
ID = a.ID,
Proposal_ID = a.Proposal_ID,
Cycle = a.Cycle.Description +
" "
+ a.Cycle.Year.ToString(),
Cycle_Requested_ID = a.Cycle_Requested_ID,
Status = a.Status,
Status_Description = a.Beamtime_Request_Statuses.Description
}).ToList();
DataSourceResult result = vm.ToDataSourceResult(request);
return
Json(result, JsonRequestBehavior.AllowGet);
}
}
01.
public
ActionResult UpdateUnitListItemViewModel([DataSourceRequest] DataSourceRequest request, UnitListItemViewModel unitListItemViewModel)
02.
{
03.
if
(ModelState.IsValid)
04.
{
05.
// Map a unit and save it
06.
Unit unit = UnitRepository.GetUnit(unitListItemViewModel.UnitID);
07.
08.
unit.Property.StatusID = unitListItemViewModel.PropertyStatusID;
09.
unit.Property.SubStatusID = unitListItemViewModel.PropertySubStatusID;
10.
11.
unit.StatusID = unitListItemViewModel.UnitStatusID;
12.
unit.SubStatusID = unitListItemViewModel.UnitSubStatusID;
13.
14.
15.
PropertyRepository.Update(unit.Property, LoggedInUser.UserID);
16.
UnitRepository.Update(unit, LoggedInUser.UserID);
17.
18.
}
19.
return
Json(
new
[] { unitListItemViewModel }.ToDataSourceResult(request, ModelState));
20.
21.
}
01.
@(Html.Kendo().Grid<
ARPS.OpsPortal.Models.UnitListItemViewModel
>()
02.
.Name("Grid")
03.
.DataSource(datasource => datasource
04.
.Ajax()
05.
.Group( group => group.Add(c => c.MarketName))
06.
.Sort( sort => sort.Add("FormattedAddress").Ascending())
07.
.Read(read => read.Action("GetUnitListItemViewModels", "Property"))
08.
.Update(update => update.Action("UpdateUnitListItemViewModel","Property"))
09.
.Model(model => model.Field(p => p.FormattedAddress).Editable(false))
10.
.Model(model => model.Field(p => p.Name).Editable(false))
11.
.Model(model => model.Id(u => u.UnitID))
12.
)
13.
.Columns(columns =>
14.
{
15.
columns.Bound(u => u.FormattedAddress).Title("Address");
16.
columns.Bound(u => u.Name).Title("Unit");
17.
columns.Bound(u => u.PropertyStatusName).Title("Property Status");
18.
columns.Bound(u => u.PropertySubStatusName).Title("Property Sub Status");
19.
columns.Bound(u => u.UnitStatusName).Title("Unit Status");
20.
columns.Bound(u => u.UnitSubStatusName).Title("Unit Sub Status");
21.
columns.Bound(u => u.AssignedUserInitials).Title("User");
22.
columns.Command(command => command.Edit());
23.
})
24.
.Editable(editable => editable.Mode(GridEditMode.InLine))
25.
.Pageable()
26.
.Sortable()
27.
)
01.
@(Html.Kendo().DropDownList()
02.
.Name("PropertySubStatusID")
03.
.HtmlAttributes(new { style = "width:150px" })
04.
05.
.DataTextField("Name")
06.
.DataValueField("StatusID")
07.
.DataSource(source => {
08.
source.Read(read =>
09.
{
10.
read.Action("GetActiveSubStatuses", "Status")
11.
.Data("filterPropertySubStatuses");
12.
})
13.
.ServerFiltering(true);
14.
})
15.
.Enable(true)
16.
.SelectedIndex(0)
17.
.AutoBind(false)
18.
.CascadeFrom("PropertyStatusID")
19.
20.
)
21.
22.
<
script
type
=
"text/javascript"
>
23.
24.
function filterPropertySubStatuses() {
25.
return {
26.
StatusID: $("#PropertyStatusID").val()
27.
};
28.
}
29.
30.
</
script
>
I have the following code to bind a DropDownList for the Status property of a User Model. The Status is an enum.
The DropDownList for the first user (row 1 in the table) is rendered correctly - however subsequent rows the DropDownList is not rendered - it is rendered as an empty text box. If I use 'Vanilla Razor' DropDownList then the controls are rendered correctly - what is wrong?
Thanks
Ian
@model IEnumerable<
CLOCS.Models.ApplicationUser
>
@{
ViewBag.Title = "Index";
}
<
h2
>Index</
h2
>
<
p
>
@Html.ActionLink("Create New", "Create")
</
p
>
<
table
class
=
"table"
>
<
tr
>
<
th
>
@Html.DisplayNameFor(model => model.UserName)
</
th
>
<
th
>
</
th
>
</
tr
>
@foreach (var item in Model)
{
<
tr
>
<
td
>
@Html.DisplayFor(modelItem => item.UserName)
</
td
>
@*<
td
>
@Html.EnumDropDownListFor(modelItem => item.Status)
</
td
>*@
<
td
>
@Html.Kendo().DropDownListFor(modelItem => item.Status).BindTo(EnumHelper.GetSelectList(item.Status.GetType()))
</
td
>
<
td
>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</
td
>
</
tr
>
}
</
table
>
@model PASSAdmin.ViewModels.ResourceReviewer.ResourceReviewViewModel
@{
bool disabled = true;
if (Model.Status == "BLREV")
{
disabled = false;
}
}
@Html.HiddenFor(model => model.Beamline_Request_ID, Model.Beamline_Request_ID)
@Html.HiddenFor(model => model.Status, Model.Status)
<
div
class
=
"editor-container"
style
=
"width:700px;"
>
<
p
>Please provide your recommendation of the experiment described in this Beam Time Request with regard to feasibility and safety.</
p
>
<
div
>
<
div
class
=
"editor-label"
>
@Html.Label("Approve")
</
div
>
<
div
class
=
"editor-field"
>
@if (disabled)
{
@Html.RadioButtonFor(model => model.Refused_By_Beamline, "N", new { disabled = true })
}
else
{
@Html.RadioButtonFor(model => model.Refused_By_Beamline, "N")
}
</
div
>
<
div
class
=
"editor-label"
>
@Html.Label("Deny")
</
div
>
<
div
class
=
"editor-field"
>
@if (disabled)
{
@Html.RadioButtonFor(model => model.Refused_By_Beamline, "Y", new { disabled = true })
}
else
{
@Html.RadioButtonFor(model => model.Refused_By_Beamline, "Y")
}
</
div
>
</
div
>
<
br
class
=
"clear"
/>
<
br
/>
<
br
/>
<
p
>By selecting Approve you are signifying the Experiment is feasible and can be performed safely on the indicated Beamline. If you select to Deny any of the above, please provide an explanation in the Comments area below. In addition to any specific comments, it is suggested you make note of any particular beamline equipment to be used during this experiment. Other staff may not have access to the full proposal information, but will have access to these comments.</
p
>
@*
<
div
class
=
"editor-label"
>
@Html.Label("Comments")
</
div
>
<
div
class
=
"editor-field"
>
@Html.EditorFor(model => model.Refused_By_Beamline, "N")
@Html.ValidationMessageFor(model => model.Refused_By_Beamline)
</
div
>
*@
<
p
>Note: comments entered here are visible to the Principal Investigator</
p
>
</
div
>
@(Html.Kendo().Grid<ExpenseReport.MVC.Models.ExpenseReportModel>()
.Name(
"Grid"
)
.Columns(columns =>
{
columns.Bound(p => p.ExpenseReportId).Visible(
true
);
columns.Bound(p => p.ExpenseLineItemId).Visible(
true
);
columns.Bound(p => p.ExpenseTypeDesc).Title(
"Expense Type"
);
columns.Bound(p => p.City).Title(
"City"
);
columns.Bound(p => p.StateName).Title(
"State"
);
columns.Bound(p => p.Date).Format(
"{0:d}"
).Title(
"Date"
);
columns.Bound(p => p.Amount).Title(
"Amount"
);
columns.Bound(p => p.EndingMileage).Title(
"Ending Mileage"
);
columns.Bound(p => p.BeginningMileage).Title(
"Beginning Mileage"
);
columns.Command(command => { command.Edit(); command.Destroy(); });
})
.ToolBar(toolbar => toolbar.Create().HtmlAttributes(
new
{ id =
"btnAdd"
}))
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName(
"NewExpense"
).Window(w => w.Width(500)))
.Pageable()
.Scrollable()
.HtmlAttributes(
new
{ style =
"height:430px; width=100%"
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error(
"error_handler"
))
.Model(model =>
{
model.Id(p => p.ExpenseReportId);
model.Id(p => p.ExpenseLineItemId);
})
.Create(create => create
.Action(
"EditingPopup_Create"
,
"ExpenseReport"
)
.Data(
"erLineItemsCreateData"
))
//.Read(read => read
// .Action("EditingPopup_Read", "ExpenseReport")
// .Data("erLineItemsReadData"))
.Update(update => update
.Action(
"EditingPopup_Update"
,
"ExpenseReport"
).Type(HttpVerbs.Post)
.Data(
"erLineItemsUpdateData"
))
.Destroy(update => update
.Action(
"EditingPopup_Destroy"
,
"ExpenseReport"
).Type(HttpVerbs.Post)))
)
<script>
function
error_handler(e) {
if
(e.errors) {
var
message =
"Errors:\n"
;
$.each(e.errors,
function
(key, value) {
if
(
'errors'
in
value) {
$.each(value.errors,
function
() {
message +=
this
+
"\n"
;
});
}
});
alert(message);
}
}
//pass additional data to the READ action method
function
erLineItemsReadData() {
return
{
expenseReportId:
"@ViewBag.ExpenseReportId"
};
}
function
erLineItemsCreateData() {
return
{
expenseReportId:
"@ViewBag.ExpenseReportId"
};
}
function
erLineItemsUpdateData() {
return
{
expenseReportId:
"@ViewBag.ExpenseReportId"
,
expenseLineItemId:
"@ViewBag.ExpenseLineItemId"
};
}
[AcceptVerbs(HttpVerbs.Post)]
public
ActionResult EditingPopup_Update([DataSourceRequest] DataSourceRequest request, ExpenseReportModel erLineItem,
int
expenseReportId,
int
expenseLineItemId)
{
if
(erLineItem !=
null
&& ModelState.IsValid)
{
globalKip.UpdateExpenseReportLineItem(expenseReportId, erLineItem.ExpenseTypeDesc, erLineItem.Date, erLineItem.Amount, erLineItem.City, erLineItem.StateName, erLineItem.EndingMileage, erLineItem.BeginningMileage);
}
return
Json(
new
[] { erLineItem }.ToDataSourceResult(request, ModelState));
}