completato fix sorting (oltre a filtro + ricerca) --> manca solo paginazione!

This commit is contained in:
Samuele E. Locatelli (WEB DEV)
2016-10-20 23:41:54 +02:00
parent 1ce90e9ee5
commit fda7d2fe9c
4 changed files with 12 additions and 7 deletions
@@ -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 != "");
+7 -2
View File
@@ -11,6 +11,7 @@
<div class="row">
<div class="col-sm-2">
<strong>Configurazione Posizioni</strong>
@Html.Hidden("SortOrd")
</div>
<div class="col-sm-2">
@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() {
@@ -3,12 +3,10 @@
<table class="table table-condensed table-responsive table-striped table-hover table-bordered">
<tr>
<th>
@*@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 })
</th>
<th>
@*@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 })
</th>
<th></th>
</tr>
Binary file not shown.