pagedlist 相关问题

PagedList使.Net开发人员更容易编写分页代码。它允许您获取任何IEnumerable(T)并通过指定页面大小和所需的页面索引,仅选择该列表的子集。 PagedList还提供了在构建UI分页控件时有用的属性。

使用 MudBlazor MudDataGrid ServerData 从 API 加载分页数据

在我看来,当涉及到从动态源(例如 API)加载分页数据时,MudDataGrid 的文档有点缺乏。 如何使用 ServerData 属性? 我该如何处理行

回答 1 投票 0

分页库,重置PageKeyedDataSource

我使用 Android Paging 库为我的列表实现了无限滚动。我根据页面分部分从 API 下载数据。我的应用程序允许用户通过添加一些参数来过滤项目......

回答 1 投票 0

Model is Invalid always - 每次使用EF Core添加数据时都会出现错误。

我使用ASP.Net Corre 3.1。我的模型是这样的-- public class Review.BaseEntity { [required] [Range(1,10)] public float: BaseEntity { [Required] [Range(1,10)] public float Rating { get; set; }。Required(ErrorMessage = "Movie ..."。

回答 1 投票 0

如何在asp.net核心中使用分页列表实现多重分页?

我是asp.net核心的新手。我有按年份分组的列表,我想对它们的子项进行分页。我现在可以使用pagedList来分页一个简单的列表。非常感谢!那是我的剃须刀页面: ] >>> 下面是使用Bootstrap分页的解决方案。 在ProductController.cs中: using System.Linq; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; namespace TestControllers { public class ProductController : Controller { private readonly ILogger<ProductController> _logger; public ProductController(ILogger<ProductController> logger) { _logger = logger; } public IActionResult Products() { //Generate test products data var products = Enumerable.Range(1,1000).Select(i=> new Product(){Id=i,BrandId=i%10+1, CategoryId=i%20 + 1, ExpirationDate="12/"+(i%31 + 1) + "/2020", Name="Product"+i, OriginCity="City"+(i%40 + 1), OriginCountry="Country"+(i%50 + 1), ProducerName="Producer"+ i+100 + 1, ProductionDate="1/"+(i%31 + 1) + "/2020"} ).ToList(); return View(products); } } public class Product { public int Id { get; set; } public int CategoryId { get; set; } public int BrandId { get; set; } public string Name { get; set; } public string ProducerName { get; set; } public string OriginCity { get; set; } public string OriginCountry { get; set; } public string ProductionDate { get; set; } public string ExpirationDate { get; set; } } } 在Product.cshtml中: @model List<TestControllers.Product> @using System.Linq; @{ ViewData["Title"] = "Products Page"; var category = this.Context.Request.Query["category"]; var page = this.Context.Request.Query["page"]; var categoryInt = !string.IsNullOrEmpty(category) ? int.Parse(category) : 1; var pageInt = !string.IsNullOrEmpty(page) ? int.Parse(page) : 1; var productsPerPage = 10; //Get pager contents Func<string,string, int, int,int, Func<int,Dictionary<string,string>>, string> getPager = (controller,action,pages, currentPage,numberOfPages, getParameters) => { //Get query string for a given page number Func<int, string> getQueryString = (page1) => { var queryString = getParameters(page1).ToList().Aggregate("", (content, next) => { content = !string.IsNullOrEmpty(content) ? content + "&" : content; content += string.Format("{0}={1}", next.Key, next.Value); return content; }); queryString = !string.IsNullOrEmpty(queryString) ? "?" + queryString : queryString; return queryString; }; var pager = "<nav aria-label=\"...\"><ul class=\"pagination .pagination-lg\">"; if(currentPage>1) { pager+= "<li class=\"page-item\"><a class=\"page-link\" href=\"" + string.Concat("/", controller, "/", action, getQueryString(currentPage-1)) + "\">Previous</a></li>"; } else { pager += "<li class=\"page-item disabled\"><span class=\"page-link\">Previous</span></li>"; } var renderedPageSets = new List<List<int>>(); var renderedPages = 0; if(pages<= numberOfPages) { renderedPageSets.Add(Enumerable.Range(1, pages).ToList()); } else { while (renderedPages < pages) { var lastSetPage = renderedPages + numberOfPages; if (lastSetPage <= pages) { renderedPageSets.Add(Enumerable.Range(++renderedPages, numberOfPages).ToList()); } else { renderedPageSets.Add(Enumerable.Range(pages - numberOfPages + 1, numberOfPages).ToList()); } if(renderedPageSets.Last().Contains(currentPage)) { break; } renderedPages = lastSetPage; } } var renderedPageSet = renderedPageSets.First(s => s.Contains(currentPage)); if(renderedPageSet.First()!=1) { pager += "<li class=\"page-item disabled\"><span class=\"page-link\">...</span></li>"; } pager = renderedPageSet.Aggregate(pager, (currentPagerContent, nextPage) => { currentPagerContent += "<li class=\"page-item"+(currentPage==nextPage? " active":"") + " \"><a class=\"page-link\" href=\""+string.Concat("/",controller,"/",action, getQueryString(nextPage)) + "\">"+nextPage+"</a></li>"; return currentPagerContent; }); if (renderedPageSet.Last() != pages) { pager += "<li class=\"page-item disabled\"><span class=\"page-link\">...</span></li>"; } if (currentPage < pages) { pager += "<li class=\"page-item\"><a class=\"page-link\" href=\"" + string.Concat("/", controller, "/", action, getQueryString(currentPage + 1)) + "\">Next</a></li>"; } else { pager += "<li class=\"page-item disabled\"><span class=\"page-link\">Next</span></li>"; } pager += "</li></ul></nav>"; return pager; }; } <div class="text-center"> <h1 class="display-4">Products</h1> </div> <div class="card" style=""> <div class="card-header"> <div> @{ var categories = Model.Select(i => i.CategoryId).Distinct().Count(); } <h2>Categories:</h2> @Html.Raw(getPager("Product", "Products", categories, categoryInt, 10, (category1) => { return new Dictionary<string, string>() { { "page", "1" }, { "category", category1.ToString() } }; })) </div> <h3>Products in category @categoryInt</h3> </div> <br /> <a asp-action="Add" asp-controller="Product" class="btn btn-success btn-sm" style="width:148px">Add a New Product</a> <table class="table table-bordered"> <tr> <th>Category</th> <th>Name</th> <th>Producer Name</th> <th>Origin City</th> <th>Origin Country</th> <th>Production Date</th> <th>Expiration Date</th> <th>&nbsp;</th> </tr> @foreach (var product in Model.Where(i => i.CategoryId == categoryInt).Skip((pageInt - 1) * productsPerPage).Take(productsPerPage)) { <tr> <td>@product.CategoryId</td> <td>@product.Name</td> <td>@product.ProducerName</td> <td>@product.OriginCity</td> <td>@product.OriginCountry</td> <td>@product.ProductionDate</td> <td>@product.ExpirationDate</td> <td> <a asp-action="Edit" asp-controller="Product" asp-route-id="@product.Id" class="btn btn-warning btn-sm">Edit</a> <a asp-action="Delete" asp-controller="Product" asp-route-id="@product.Id" class="btn btn-danger btn-sm">Delete</a> </td> </tr> } </table> <div> @{ var categoryProductsPages = (int)Math.Ceiling(((double)Model.Where(i => i.CategoryId == categoryInt).Count()) / productsPerPage); } @Html.Raw(getPager("Product", "Products", categoryProductsPages, pageInt, 10, (page1) => { return new Dictionary<string, string>() { { "page", page1.ToString() }, { "category", category } }; })) </div> </div>

回答 1 投票 0

使用PagedList的自定义分页asp.net

我本学期开始学习ASP.NET。我们分配了一个简单的3x2画廊,并且还需要以指定的方式显示分页(对不起,我的英语)。我们正在使用ASP ....

回答 1 投票 0

将PagedList用于分页产品列表

我正在尝试显示产品列表并显示分页。因此,我决定使用PagedList插件。我在下面的链接中阅读了一些有关如何修改控制器并进行查看的示例。 https:// github ....

回答 1 投票 0

MVC C#PagedList-PagedListPager将int数组作为参数传递

我不知道如何传递一个int数组。让我们看看我的代码... @ Html.PagedListPager(Model,pagina => Url.Action(“ Index”,new {pagina,codOccu = ViewBag.codOccu,// int数组...

回答 1 投票 0

在模式弹出窗口上使用X.PagedList

我在页面上弹出了一个模式弹出窗口:...

回答 1 投票 0

PagedList丢失其值,因为它一直在调用httpGet方法

我有以下代码,显示我正在使用PagedList来按页面顺序显示搜索结果。它的问题是,在搜索的第一个结果中,它显示了页面数...

回答 1 投票 0

分页列表(数据库+网络)在更新数据库记录时触发onItemAtEndLoaded

我正在使用分页列表库构建一个recyclerView。我从本地数据库中获取项目,当它到达最后一个数据库时,onItemAtEndLoaded()被触发,然后调用API来...

回答 1 投票 1

尝试在MVC4中使用ViewModel进行分页

我不想从数据库中获取所有项目并将它们转换为特定的Viewmodel,然后使用PagedList库来分页所有这些数据。例如,我想在一页上获得20个项目,但我不希望...

回答 2 投票 2

刷新数据后,RecyclerView似乎在屏幕上向下移动

使用LiveData 以显示访问Room数据库的回收者视图。当我在屏幕上进行搜索时,返回的项目数较少,但是,似乎有很多额外的...

回答 1 投票 1

在ASP.Net Core中使用分页传递模型参数

我正在使用PagedList在ASP.Net Core应用程序的表上工作。我需要在页面更改时将模型传递给控制器 ,但是没有发送。 ...

回答 1 投票 0

“IEnumerable <>”类型在未引用的程序集中定义

我已将以下nuget包添加到我的MVC 5应用程序X.PagedList.Mvc我在控制器/视图中返回结果如下:// Repo public IPagedList GetPagedPosts(int ...

回答 2 投票 17

从RecyclerView迁移到PagedListAdapter,数据不会显示在submitList(Android Studio JAVA)

我刚刚实现了Android组件的新架构,Room,ViewModel,LiveData,Retrofit和RecyclerView,所以没问题,问题是我在recyclerview中显示的列表是指数式的......

回答 1 投票 0

如何在Android中搜索/过滤分页列表数据源

问题我正在使用PagedList设置数据。如何在使用Room时过滤/搜索列表。我已经尝试过滤DataSource类上的列表,同时发出请求但想要...

回答 1 投票 -1

PagedListPager传递其他模型数据

我有以下模型:公共类PagedClientViewModel {public int?第{页;组; public PagedList.PagedList 客户{get;组; } ...

回答 2 投票 5

Pagedlist分页链接中的Href属性为空

PagedListPager方法正在生成分页链接(锚标记),但它们的href属性为空/空。请参阅View @ Html.PagedListPager中的图像代码(Model,page => Url.Action(“Orders”,...

回答 1 投票 1

如何使用recyclelerView和PagedListAdapter滚动到顶部时编写实现?

我使用Android Jetpack组件来开发我的聊天应用程序,我想在聊天日志屏幕中添加对分页的支持,因为从数据源获取数据并在...中呈现消息时花费的时间太长了...

回答 1 投票 0

分页时MVC持久模型

我有一个带有复选框的下拉列表。选定的值绑定到我的视图模型。使用PagedList.Mvc分页数据。当我选择一些复选框然后点击搜索时,一切正常...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.