completata review metodi pagina index principale x locations

This commit is contained in:
Samuele E. Locatelli
2016-10-21 10:03:33 +02:00
parent 2ec5f00973
commit 67ecee03e8
4 changed files with 18 additions and 23 deletions
@@ -42,10 +42,10 @@ namespace StockManMVC.Controllers
if (LocTypeID == null) LocTypeID = "";
if (SearchVal == null) SearchVal = "";
if (SortOrd == null) SortOrd = "";
//if (page == null) page = 1;
//if (pageSize == null) pageSize = 5;
int PageSize = 5;
int PageNum = (page ?? 1);
if (page == null) page = 1;
if (pageSize == null) pageSize = 5;
//int PageSize = 5;
//int PageNum = (page ?? 1);
ViewBag.LocTypeID = LocTypeID;
ViewBag.SearchVal = SearchVal;
@@ -78,9 +78,9 @@ namespace StockManMVC.Controllers
}
ViewBag.LocTypeID = LocTypeID;
return PartialView("_ListByType", CurrLocations.ToList());
//return PartialView("_ListByType", CurrLocations.ToPagedList(PageNum, PageSize));
//return PartialView("_ListByType", CurrLocations.ToPagedList((int)page, (int)pageSize));
}
// GET: Locations/Create (mode=std|full, opzionale)
public ActionResult Create(string mode)
{
+6 -16
View File
@@ -1,6 +1,4 @@
@model IEnumerable<StockManMVC.Models.Location>
@*@model PagedList.IPagedList<StockManMVC.Models.Location>*@
@using PagedList.Mvc;
@{
ViewBag.Title = "Configurazione Posizioni";
@@ -13,7 +11,6 @@
<div class="row">
<div class="col-sm-2">
<strong>Configurazione Posizioni</strong>
@Html.Hidden("SortOrd")
</div>
<div class="col-sm-2">
@Html.DropDownList("LocTypeDD", null, "-- TUTTI --", htmlAttributes: new { @class = "form-control" })
@@ -28,10 +25,8 @@
</div>
<div class="panel-body small">
<div id="mainDiv" class="col-xs-12">
@Html.Action("ListByType", new { LocTypeID = @ViewBag.LocTypeID })
<div>
@*@Html.PagedListPager(Model, page => Url.Action("Index", new { page, sortOrder = ViewBag.SortOrd, currentFilter = ViewBag.CurrentFilter }))*@
pag @Html.TextBox("page") / @Html.TextBox("pageSize")
<div id="mainDivGrid">
@Html.Action("ListByType", new { LocTypeID = @ViewBag.LocTypeID, page = ViewBag.page, pageSize = ViewBag.pageSize })
</div>
</div>
<div class="col-xs-6">
@@ -48,13 +43,11 @@
function refreshSelectedData() {
var LocTypeID = $("#LocTypeDD").val();
var SearchVal = $("#SearchVal").val();
var SortOrd = $("#SortOrd").val();
var page = $("#page").val();
var pageSize = $("#pageSize").val();
$("#mainDiv").load('@(Url.Action("ListByType", "Locations", null, Request.Url.Scheme))?LocTypeID=' + LocTypeID + '&SearchVal=' + SearchVal + '&SortOrd=' + SortOrd + '&page=' + page + '&pageSize=' + pageSize);
var queryUrl = 'LocTypeID=' + LocTypeID + '&SearchVal=' + SearchVal + '&SortOrd=@ViewBag.SortOrd&page=@ViewBag.page&pageSize=@ViewBag.pageSize';
// ricarico
$("#mainDivGrid").load('@(Url.Action("ListByType", "Locations", null, Request.Url.Scheme))?' + queryUrl);
// modifico URL!
history.replaceState('LocTypeID=' + LocTypeID, 'Locations', '?LocTypeID=' + LocTypeID + '&SearchVal=' + SearchVal + '&SortOrd=' + SortOrd + '&page=' + page + '&pageSize=' + pageSize)
history.replaceState('LocTypeID=' + LocTypeID, 'Locations', '?' + queryUrl)
}
$(document).ready(function () {
$("#LocTypeDD").change(function () {
@@ -63,9 +56,6 @@
$("#SearchVal").change(function () {
refreshSelectedData();
});
$("#SortOrd").change(function () {
refreshSelectedData();
});
});
function LoadCreateNew() {
@@ -30,4 +30,9 @@
</td>
</tr>
}
</table>
</table>
<div>
@*@Html.PagedListPager(Model, page => Url.Action("Index", new { page, SearchVal = ViewBag.SearchVal, SortOrd = ViewBag.SortOrd, currentFilter = ViewBag.CurrentFilter }))*@
@Html.TextBox("page") / @Html.TextBox("pageSize")
</div>
Binary file not shown.