问题标签 [pagedlist]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
149 浏览

.net - PagedList 非常冗余和重复的代码

我的页面上有分页列表,它允许 5 个页面查看结果,其格式为 www.example.com/viewing?1 ... 2 ...3 一直到 5,我正在检查我是哪个页面在做

然后

一直到 5 .. 有没有更好的方法来做到这一点这里是代码..

0 投票
0 回答
440 浏览

asp.net-mvc-3 - Tablesorter VS PagedList

我正在做一个项目,我必须从数据库中获取数据,然后将结果显示在至少 200 行直到 3000 行的表中。

我尝试了第一个 Pagedlist 并注意到每页只显示固定数量的记录在客户端,并且每次用户更改页面时,都会向服务器发出新请求。

对于tablesorter,我注意到所有结果都显示了,分页只是视觉的(只有表格的呈现),但一切都在客户端

我的理解正确吗?

我想知道哪种方法更好(及时执行)?

实际上我在本地主机上工作,只有我作为用户,所以我无法注意到差异,即使 tablesorter 第一次加载需要更多时间,但是在它非常快之后,同时 pagedlist 方法在加载页面时更快,但每次它请求服务器更改页面并加载相应的数据

完成后,应用程序将在服务器中,许多用户将有权访问应用程序以添加、搜索删除...

这两种方法中哪一种是更好的选择?

谢谢

0 投票
2 回答
1583 浏览

c# - MVC - 分页列表:使用文本框、复选框和下拉列表将我的所有值保存在内存中

我正在构建一个 MVC 应用程序,它将在屏幕上显示一些数据。我最终可能会拥有数百甚至数千个数据。

所以我在本教程之后使用 PagedList 格式:

http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net- mvc-应用程序

这对我有帮助。分页列表有效。但是我有一个问题,我似乎无法弄清楚如何解决。在本教程中,只有 1 个参数,一个文本框,本教程通过保留和归属 ViewBag 参数将值“保存在内存中”,这样更改页面就不会“刷新”文本框中的文本。

现在我正在构建一个类似搜索引擎的东西,现在有 23 个参数和计数。这些参数包括复选框、文本框和下拉列表。

我的问题:有什么办法可以将这些保存在内存中?我该如何进行?我必须像教程一样将它们全部保存在内存中吗?

非常感谢!

0 投票
5 回答
20796 浏览

asp.net-mvc - 将 @Html.DisplayNameFor() 与 PagedList 一起使用

我一直在尝试 PagedList 包来为我的索引视图获取分页。一切进展顺利,在控制器级别一切正常,每页仅显示 5 条记录,并根据查询字符串显示适当的页面。

我的问题在视图中。我将 @Model 更改为,PagedList.IPagedList以便可以访问Model.HasNextPage和其他属性,但现在@Html.DisplayNameFor(model => model.ItemName)不再工作。我收到此错误:

PagedList.IPagedList<Dossier.Models.Item>' does not contain a definition for 'ItemName' and no extension method 'ItemName' accepting a first argument of type 'PagedList.IPagedList<Dossier.Models.Item>' could be found (are you missing a using directive or an assembly reference?)

以下是视图的相关部分:

似乎 IPagedList 与 DisplayNameFor() 不兼容。知道为什么会发生这种情况,以及我该如何解决?我知道我可以手动输入列名,但我希望该信息稍后保留(并且可以更改)在模型中。

0 投票
2 回答
2028 浏览

asp.net-mvc - 使用 PagedList 时从控制器设置 ASP MVC3 下拉列表项

我有一个使用PagedList的页面,但也包含一个用于排序的下拉列表。问题是,每当有人使用下拉列表项进行排序时,每当他们点击“下一个”或“后退”时,下拉列表项都会恢复为默认值,程序通过控制器运行默认(基本上是空白)排序标准,当您导航到第二页或第二页(并返回)时,您会丢失已排序的项目。

这是用于此页面的控制器:

这是视图中的下拉列表:

并且(以防万一)下面是<div>包含视图中的 PagedList 导航按钮的:

0 投票
1 回答
213 浏览

ajax - MVC - Ajax - Chrome 和 IE 9 之间的不一致

我有一个 MVC 视图,我正在使用该PagedList组件对数据进行一些分页。我支持此功能的 JavaScript 如下所示:

我的 .cshtml 文件部分看起来像这样:

在 IE9 中,这非常有效。当我单击特定页码或下一页/上一页时,将对我的控制器进行异步调用以刷新数据列表(“​​itemList”)。但是,在 Chrome 中,对我的控制器进行了两次调用。一个是 Ajax 调用,另一个不是。谁能告诉我为什么在 Chrome 中对我的控制器进行了两次调用?如果您需要查看更多代码,请告诉我。

0 投票
6 回答
9103 浏览

entity-framework-4 - SqlParameter 已被另一个 SqlParameterCollection 包含

我正在使用 EF DbContext SqlQuery 来获取使用 PagedList (https://github.com/TroyGoode/PagedList)的分页对象列表,我收到以下错误:

“SqlParameter 已被另一个 SqlParameterCollection 包含”

这是我的存储库代码:

但是当我在 SqlQuery 语句上调用 ToList 扩展时,它工作正常:

分页列表代码:

我已经解决了以下问题,但没有成功:

我可以做些什么来解决我遇到的错误?

0 投票
0 回答
1158 浏览

asp.net-mvc - Using additional filters with PagedList and a ViewModel

I need to know how to get additional properties added to the object returned by PagedList.Mvc package when I use ToPagedList so that I can avoid using ViewBags to pass sort order parameters around.

I know that when using ToPagedList it converts an IEnumerable into an IPagedList and I've made my view Strongly Typed to PagedList.IPagedList<MyModel> which allows me to get paging and use a foreach to display the results in a table. However there doesn't seem to be any way for me to pass along additional values such as my sort order or filter string.

I'm using AutoMapper to map between my domain and ViewModel like this to flatten my domain model into a ViewModel:

so that to return data in my controller I can do

So that in my View I can strongly type it like this

Which in turn allows me to get the paging I want with a nice simple

and to display my list of Todo Items use a

to iterate through them

As I said the trouble is that I also want to have properties such as the SortOrder, SearchFilter and IncludeCompleted in my ViewModel because at present they're being passed around in ViewBags and I'd like to clean that up.

But because they're not part of the ToDo entity, they really belong on the ToPagedList extensions I'm stuck. Ideally I'd like to somehow pass them along with the other properties that are exposed by being a PagedList such as PageCount or PageNumber, but short of deriving my own PagedList or forking the original I don't see how I can support passing such properties. All the examples on the github page make heavy use of ViewBag.

I've been unable to add a wrapper class around my IndexToDoViewModel so it has an IEnumerable or IPagedList as well as the sorting properties as this then makes my AutoMappings invalid.

Am I stuck with using ViewBags for the SortOrder filter or is there a way to have my cake and eat it by getting the properties included in my ViewModel, using AutoMapper and keeping the view strongly typed?

0 投票
1 回答
1031 浏览

asp.net-mvc-3 - ViewModel 中的 MVC3 IPagedList

我想有一个页面,在页面顶部有一个表格,可以在系统中输入电影,在页面底部,我希望有一个表格来显示库存中的所有电影。我收到一条错误消息:值不能小于 1。参数名称:页面大小。

我有一个当前看起来像这样的视图模型:

在我的控制器中,我有:

在我看来,我有:

0 投票
1 回答
1899 浏览

asp.net-mvc-4 - Asp.Net MVC 分页列表和传递搜索条件

我在我的 MVC 页面上使用 Troy Goode 的 PagedList 扩展。通过呈现包含给定记录页面的部分内容,它可以正常工作。

现在我必须实现搜索结果的过滤。我正在使用 AJAX 表单来获取与给定搜索条件匹配的部分包含结果。如果结果少于一页,这很有效。如果过滤结果超出一页,则存在问题。当点击分页链接时,过滤信息消失了,它会导致下一页未过滤信息。

当输入某些内容来过滤搜索结果并且有分页链接时,我可以使用什么机制来传递过滤信息?