asp.net-mvc asp.net mvc 的最佳列表视图解决方案?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4875594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Best List view solution for asp.net mvc?
提问by s_h
Its common to observe listview developments for webforms but no common in mvc. on the other hand for mvc I′m only finding grid views displaying tabular data.
观察 webforms 的 listview 开发很常见,但在 mvc 中不常见。另一方面,对于 mvc,我只找到显示表格数据的网格视图。
In your opinion which is the best List view solution for asp.net mvc?.
在您看来,哪个是 asp.net mvc 的最佳列表视图解决方案?。
Edited: ok, finally I found a possibility. Kazi Manzur wrote a listview using telerik controls. http://weblogs.asp.net/rashid/archive/2010/03/24/creating-rich-view-components-in-asp-net-mvc.aspx
编辑:好的,最后我找到了一种可能性。Kazi Manzur 使用 Telerik 控件编写了一个列表视图。http://weblogs.asp.net/rashid/archive/2010/03/24/creating-rich-view-components-in-asp-net-mvc.aspx
回答by Mikael Eliasson
In MVC you usually just create a loop and write the list yourself.
在 MVC 中,您通常只创建一个循环并自己编写列表。
<ul>
@foreach (var message in Model.Messages)
{
<li>@message</li>
}
</ul>
This programming model gives you more control and fits MVC much better so I don't think there is a need for something like the webforms listview.
这种编程模型为您提供了更多控制权并且更适合 MVC,因此我认为不需要像 webforms listview 这样的东西。
UPDATE: Adding pagingsupport is quite easy with a HtmlHelper. See http://rickyrosario.com/blog/simple-htmlhelper-extension-for-paging-in-asp-net-mvc/Look at the pages linked from the post too.
更新:使用 HtmlHelper 添加分页支持非常容易。参见http://rickyrosario.com/blog/simple-htmlhelper-extension-for-paging-in-asp-net-mvc/查看帖子中链接的页面。
回答by Khalid Abuhakmeh
Remember that ASP.NET MVC puts the power of HTML in your hands. This opens up access to a variety of open source widget libraries.
请记住,ASP.NET MVC 将 HTML 的力量置于您的手中。这打开了对各种开源小部件库的访问。
- JQuery UI
- ExtJS (Sencha)
- MooTools
- jQuery 用户界面
- ExtJS (煎茶)
- MooTools
You will be ultimately be responsible for creating the HTML, but a lot of these libraries offer guidance as to what that HTML will look like.
您将最终负责创建 HTML,但很多这些库都提供有关 HTML 外观的指导。
回答by Ely
The jQuery Grid plugin is pretty good: http://www.trirand.com/blog/. It requires you to write the table yourself, but then gives you lots of power for paging/sorting, etc...
jQuery Grid 插件非常好:http: //www.trirand.com/blog/。它要求您自己编写表格,但随后为您提供了大量的分页/排序等功能......
MVCContrib has a grid component that is real slick and might be more what you are use to coming from a webforms background: http://mvccontrib.codeplex.com
MVCContrib 有一个非常漂亮的网格组件,并且可能更适合您来自 webforms 背景的使用:http: //mvccontrib.codeplex.com
Microsoft is also working on a grid jQuery plugin, but I think that is still a ways off.
微软也在开发网格 jQuery 插件,但我认为这还有很长的路要走。
回答by schellack
The examples of using a ListView that I have seen also add in jQuery Tablesorter plugin. This postshows an example of using with jQuery to get both sorting and paging support.
我所看到的使用 ListView 的示例也在 jQuery Tablesorter 插件中添加。这篇文章展示了一个使用 jQuery 来获得排序和分页支持的例子。
And here's another post showing the user of the Listview with the jQuery Tablesorter plugin: http://beckelman.net/post/2008/10/16/Client-Side-ASPNET-ListView-Sorting-via-jQuery-TableSorter-Plugin-Demo.aspx
这是另一篇文章,展示了使用 jQuery Tablesorter 插件的 Listview 用户:http://beckelman.net/post/2008/10/16/Client-Side-ASPNET-ListView-Sorting-via-jQuery-TableSorter-Plugin-演示.aspx