ASP.NET MVC4开发指南_vue mvc

ASP.NET MVC4开发指南_vue mvcWhatistheWebGrid?TheWebGridisahelperthatwasincludedonthenewBeta1versionofASP.NETMVC3(Changescanhappenssinceitisabetaversion)thatenableustoshowdataeasily.Withasimp…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

What is the WebGrid?

The WebGrid is a helper that was included on the new Beta 1 version of ASP.NET MVC 3 (Changes can happens since it is a beta version) that enable us to show data easily.

With a simple command @grid.getHtml() we have as return a populated table, with paging, sorting and alternated lines. Want more? yes, it follows the webstandards.

The WebGrid constructor takes a number of parameters. Only one is mandatory. Here’s an explanation of all of them:

System.Collections.Generic.IEnumerable sourceThe collection of objects

System.Collections.Generic.IEnumerable columnNames = nullThe names of the columns appearing in the grid

string defaultSort = null

The name of the column to sort the grid by default

int rowsPerPage = 10The number of rows to display per page is paging is enabled

bool canPage = trueDetermines if the WebGrid can be paged

bool canSort = trueDetermines if the WebGrid can be sorted

string ajaxUpdateContainerId = nullThe id of the containing element for Ajax paging and sorting support

string ajaxUpdateCallback = nullThe callback function for Ajax paging and sorting support

string fieldNamePrefix = nullThe value which prefixes the default querystring fields

string pageFieldName = nullA value that replaces the default querystring page field

string selectionFieldName = nullA value that replaces the default querystring row field

string sortFieldName = nullA value that replaces the default querystring sort field

string sortDirectionFieldName = nullA value that replaces the default querystring sortdir field

The GetHtml method renders the grid. To render a simple grid with no formatting, use the following code. I’m using the model that’s being passed in to the view for these examples.

Controller:

public ActionResult WebGrid()

{

return View(VideoRepository.FindAll().OrderByDescending(v=>v.CreateTime));

}

View:

@model IEnumerable

@{

ViewBag.Title = “WebGrid”;

Layout = “~/Areas/Admin/Views/Shared/Layout.cshtml”;

}

WebGrid

@{

var grid = new WebGrid(Model, rowsPerPage: 2);

@grid.GetHtml(

tableStyle: “data-table”,

columns: grid.Columns(

grid.Column(“Title”),

grid.Column(header: “Image”, format: (item) => Html.Raw(string.Format(“%7B0%7D%5C%22“, item.ImageName))),

grid.Column(“CreateTime”, format: (item) => string.Format(“{0:d}”, item.CreateTime))

)

)

}

CSS:

/* data-table */

.data-table

{

border: #DDDDDD 1px solid;

width: 100%;

background:#FFF;

}

.data-table thead th

{

padding: 5px 10px;

text-align: left;

border: 1px solid #DDDDDD;

border-bottom: 1px solid #C1C8D2;

background-color: #F2F4F6;

font-size: 13px;

}

.data-table td

{

line-height: 20px;

padding: 5px 10px;

border: 1px solid #DDDDDD;

}

.data-table tr:hover

{

background-color: #F3F3F3;

}

.data-table td a

{

text-decoration: underline;

}

.data-table tfoot td

{

font-weight: bold;

padding: 10px 0;

text-align: center;

}

.data-table tfoot a

{

border: 1px solid #9AAFE5;

color: #2E6AB1;

display: inline-block;

margin: 0 2px;

padding: 0 5px;

text-decoration: none;

}

Result:

2509349417392372736.png

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/188881.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • pycharm推荐配色和字体_pycharm代码颜色

    pycharm推荐配色和字体_pycharm代码颜色pycharm的默认主题和字体什么的真是不敢恭维,尤其是在用惯了vscode的onedarkpro主题后,再看pycharm真是觉得有点。。。在网上找了许久,找到一款类似onedarkpro的主题,同时还下载了彩色括号的插件,换上类似vscode的字体,pycharm顿时顺眼多了。度云自取:https://pan.baidu.com/s/1Ia6oryWUXV3TKT0wjzbAc…

    2022年8月27日
    2
  • GB28181服务器_GB28181收费吗

    GB28181服务器_GB28181收费吗CarEye开发GB28181服务器有将近两年时间了,早期我们用纯C++开发了一个GB28181视频服务期,对外的接口是基于MQ协议的。这样开发出来的服务器主要有几个问题。1.SIP服务器和流媒体服务器是绑定在一个进程中的,因为没有分离,造成了视频处理和SIP服务器只能在一台服务器上运行,既不能打到GB28181协议的构架要求。也造成无法使用负载均衡的功能。2.对外接口采用了MQ通信方式。虽然MQ消息处理实时,对一些数据处理,如报警,对讲等。但MQ本身是重量级构建,不方便一些应用场景快速构建

    2022年8月31日
    2
  • linux系统查看IP地址,不显示IP地址或者只显示127.0.0.1

    linux系统查看IP地址,不显示IP地址或者只显示127.0.0.1目录一、正常情况二、异常显示,及解决办法2.1.异常情况1:查看当前linux的IP地址时,找不到IP地址;2.2.异常情况2:查看当前linux的IP地址时,IP地址显示为127.0.0.1一、正常情况在linux的doc框中输入命令:ifconfig,敲击enter键后,显示如下结果:正常显示结果上图选中的eth0中,inetaddr后面的就是linux系统…

    2022年10月20日
    3
  • emWin实战教程V2.0_powershell实战指南

    emWin实战教程V2.0_powershell实战指南转 http://www.chuxue123.com/forum.php?mod=viewthread&tid=5363&extra=page%3D1   http://www.chuxue123.com/forum.php?mod=viewthread&tid=1504下面是自己的学习笔记1.emWIN与ucGUI关系,而大家所熟悉的ucGUI,其实就是emWin的一个版本

    2022年10月10日
    3
  • ubuntu12.04 安装 opencv 2.4.8(非源代码编译)

    ubuntu12.04 安装 opencv 2.4.8(非源代码编译)

    2022年1月24日
    37
  • Python中的groupby分组

    Python中的groupby分组写在前面:之前我对于groupby一直都小看了,而且感觉理解得不彻底,虽然在另外一篇文章中也提到groupby的用法,但是这篇文章想着重地分析一下,并能从自己的角度分析一下groupby这个好东西~OUTLINE根据表本身的某一列或多列内容进行分组聚合通过字典或者Series进行分组根据表本身的某一列或多列内容进行分组聚合这个是groupby的最常见操作,根据…

    2022年5月26日
    72

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号