My question is a two part question.
1)
I am trying to pass a string from my Index view into a method (UpdateView(string selectProductionLine)
) via an ajax call. I can get the ajax call to call the method but I am unable to get the string to be anything but null.
2)
After this method (UpdateView(string selectProductionLine)
) is called, I want it to update the model and then call a partial view with that updated method. Currently I cannot get it to call that partial view.
I have been looking at several different attempts at this, links below, and have been unable to get this to work. My JS is not all that great, I am still a beginner, and I am having trouble combining what others have done.
Index View:
@(Html.Kendo().DropDownList()
.Name("productionLine-dropdown")
.DataTextField("Name")
.DataValueField("Id")
.DataSource(source =>
{
source.Read(read => { read.Action("GetDropDownList", "Home"); });
})
.Events(e =>
{
e.Close("OnClose");
})
)
<div id="Dashboard">
@Html.Partial("~/Views/Home/_Home.cshtml", Model)
</div>
Java Script:
function OnClose() {
var selectProductionLine = $("#productionLine-dropdown").data("kendoDropDownList").value();
$("#Dashboard").load('/Home/UpdateView', selectProductionLine);
}
function DropDownValue() {
var value = $("#productionLine-dropdown").data("kendoDropDownList").value();
return { selectProductionLine: value };
}
Controller:
public ActionResult _Home(DisplayViewModel dvm)
{
return PartialView(dvm);
}
public ActionResult UpdateView(string selectProductionLine)
{
DisplayViewModel dvm = new DisplayViewModel();
//Some logic
return PartialView("~/Home/_Home.cshtml", dvm);
}
Questions:
1) Pass a string from the Index into the UpdateView()
method.
2) Call the _Home
partial view from the UpdateView()
with the new ViewModel.
Thanks!
Refreshing MVC PartialView with new Model on DropDownList Change