diff --git a/StockManMVC/Controllers/LocationsController.cs b/StockManMVC/Controllers/LocationsController.cs index ec0affd..dd3c9fe 100644 --- a/StockManMVC/Controllers/LocationsController.cs +++ b/StockManMVC/Controllers/LocationsController.cs @@ -22,7 +22,7 @@ namespace StockManMVC.Controllers if (SortOrd == null) SortOrd = ""; ViewBag.LocTypeID = new SelectList(db.LocType, "ID", "Descr", LocTypeID); ViewBag.LocTypeSel = LocTypeID; - ViewBag.SearchString = SearchVal; + ViewBag.SearchVal = SearchVal; var location = db.Location.Include(l => l.LocType); return View(location.ToList()); } @@ -34,6 +34,8 @@ namespace StockManMVC.Controllers if (LocTypeID == null) LocTypeID = ""; if (SearchVal == null) SearchVal = ""; if (SortOrd == null) SortOrd = ""; + ViewBag.LocTypeSel = LocTypeID; + ViewBag.SearchVal = SearchVal; ViewBag.DescrSortParm = String.IsNullOrEmpty(SortOrd) ? "Descr_desc" : ""; ViewBag.LocTypeSortParm = SortOrd == "LocType" ? "LocType_desc" : "LocType"; var CurrLocations = db.Location.Where(s => s.ID != ""); diff --git a/StockManMVC/Views/Locations/Index.cshtml b/StockManMVC/Views/Locations/Index.cshtml index 40d14bb..b92dcb6 100644 --- a/StockManMVC/Views/Locations/Index.cshtml +++ b/StockManMVC/Views/Locations/Index.cshtml @@ -11,6 +11,7 @@
Configurazione Posizioni + @Html.Hidden("SortOrd")
@Html.DropDownList("LocTypeID", null, "-- TUTTI --", htmlAttributes: new { @class = "form-control" }) @@ -41,10 +42,11 @@ function refreshSelectedData() { var LocTypeID = $("#LocTypeID").val(); var SearchVal = $("#SearchVal").val(); - $("#mainDiv").load('@(Url.Action("ListByType", "Locations", null, Request.Url.Scheme))?LocTypeID=' + LocTypeID + '&SearchVal=' + SearchVal); + var SortOrd = $("#SortOrd").val(); + $("#mainDiv").load('@(Url.Action("ListByType", "Locations", null, Request.Url.Scheme))?LocTypeID=' + LocTypeID + '&SearchVal=' + SearchVal + '&SortOrd=' + SortOrd); // modifico URL! - history.replaceState('LocTypeID=' + LocTypeID, 'Locations', '?LocTypeID=' + LocTypeID + '&SearchVal=' + SearchVal) + history.replaceState('LocTypeID=' + LocTypeID, 'Locations', '?LocTypeID=' + LocTypeID + '&SearchVal=' + SearchVal + '&SortOrd=' + SortOrd) } $(document).ready(function () { $("#LocTypeID").change(function () { @@ -53,6 +55,9 @@ $("#SearchVal").change(function () { refreshSelectedData(); }); + $("#SortOrd").change(function () { + refreshSelectedData(); + }); }); function LoadCreateNew() { diff --git a/StockManMVC/Views/Locations/_ListByType.cshtml b/StockManMVC/Views/Locations/_ListByType.cshtml index 92e228f..aa53a8a 100644 --- a/StockManMVC/Views/Locations/_ListByType.cshtml +++ b/StockManMVC/Views/Locations/_ListByType.cshtml @@ -3,12 +3,10 @@ diff --git a/StockManMVC/bin/StockManMVC.dll b/StockManMVC/bin/StockManMVC.dll index 74825f1..c294a34 100644 Binary files a/StockManMVC/bin/StockManMVC.dll and b/StockManMVC/bin/StockManMVC.dll differ
- @*@Html.DisplayNameFor(model => model.Descr)*@ - @Html.ActionLink(Html.DisplayNameFor(model => model.Descr).ToString(), "Index", new { SortOrd = ViewBag.DescrSortParm }) + @Html.ActionLink(Html.DisplayNameFor(model => model.Descr).ToString(), "Index", new { LocTypeID = ViewBag.LocTypeSel, SearchVal = ViewBag.SearchVal, SortOrd = ViewBag.DescrSortParm }) - @*@Html.DisplayNameFor(model => model.LocType.Descr)*@ - @Html.ActionLink(Html.DisplayNameFor(model => model.LocType.Descr).ToString(), "Index", new { SortOrd = ViewBag.LocTypeSortParm }) + @Html.ActionLink(Html.DisplayNameFor(model => model.LocType.Descr).ToString(), "Index", new { LocTypeID = ViewBag.LocTypeSel, SearchVal = ViewBag.SearchVal, SortOrd = ViewBag.LocTypeSortParm })