I've got a view with a kendo grid on it. Above that I have a partial view that loads a value and stores it in a hidden. I need to be able to pass the value of this hidden field to the get, add, update, and delete methods of the grid preferably without having to load the grid via jquery (if possible).
Or is there a way that the hidden field on the view could be accessible or passed to the editortemplate for the grid so that I can make it part of the view model when a row is added or updated?
Here is the main view:
Here is the partial view loaded above the grid:
The "User_Facility_ID" is the value I need when doing the get, add, update, and delete for the grid.
Or is there a way that the hidden field on the view could be accessible or passed to the editortemplate for the grid so that I can make it part of the view model when a row is added or updated?
Here is the main view:
@model IEnumerable<
PASSAdmin.ViewModels.UserFacilityAdmin.ProposalTypeViewModel
>
@{
ViewBag.Title = "Proposal Types";
}
<
h2
>Proposal Types</
h2
>
@Html.Partial("_LastViewedUserFacility")
@{
Html.Kendo().Grid(Model)
.Name("gridProposalTypes")
.Columns(columns =>
{
columns.Command(command => { command.Edit(); }).Width(50);
columns.Bound(o => o.Code);
columns.Bound(o => o.Description);
columns.Bound(o => o.Technique_Selection_Count).Title("# Techniques");
columns.Bound(o => o.Resource_Selection_Count).Title("# Resources");
columns.Bound(o => o.Selection_Order).Title("Selection Order");
columns.Bound(o => o.Active);
columns.Command(command => { command.Destroy(); }).Width(50);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("UserFacilityAdmin/ProposalType").Window(window => window.Width(400)))
.Pageable()
.Sortable()
.DataSource(dataSource => dataSource
.Server()
.Model(model => model.Id(o => o.ID))
.Create(create => create.Action("AddProposalType", "UserFacilityAdmin"))
.Read(read => read.Action("ProposalTypes", "UserFacilityAdmin"))
.Update(update => update.Action("UpdateProposalType", "UserFacilityAdmin"))
.Destroy(destroy => destroy.Action("DeleteProposalType", "UserFacilityAdmin"))
)
.Render();
}
<
p
>User Facility: <
span
id
=
"userfacility"
></
span
></
p
>
<
input
type
=
"hidden"
name
=
"User_Facility_ID"
id
=
"User_Facility_ID"
/>
<
script
type
=
"text/javascript"
>
$(document).ready(function () {
$.post('/Search/GetLastViewedUserFacilityID', function (data) {
$("#userfacility").html(data);
$("#User_Facility_ID").val(data);
});
});
</
script
>