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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 逻辑漏洞思维导图

    逻辑漏洞思维导图逻辑漏洞思维导图逻辑漏洞,是因为代码之后是人的逻辑,人更容易犯错,是编写完程序后随着人的思维逻辑产生的不足。sql注入、xss等漏洞可以通过安全框架等避免,这种攻击流量非法,对原始程序进行了破坏,防火墙可以检测,而逻辑漏洞是通过合法合理的方式达到破坏,比如密码找回由于程序设计不足,会产生很多问题,破坏方式并非向程预防思路。…

    2022年5月30日
    32
  • 三立[通俗易懂]

    三立[通俗易懂]自传173、在佳木斯上网写作2013年1—-互动百科二零一三年一月起,我在佳木斯市的上网写作进入了第七年时间,钰香妻在市健身房练打乒乓球,照看外孙女和管理家务吃喝用穿。大女儿女婿在厦门外国语学校,二女儿女婿在本市文化公司上班。儿子在大连工业大学,儿媳在大连银行,孙女在北京上大学二年。2013、1、1星期二写《新年(七古)》:平平静静日历翻,新页…

    2022年5月4日
    66
  • MySQL之权限管理

    MySQL之权限管理MySQL之权限管理

    2022年4月24日
    50
  • WIN7系统配置maven环境变量「建议收藏」

    WIN7系统配置maven环境变量「建议收藏」1.maven程序包下载地址:maven下载后解压到想要安装的位置,我直接放到C盘下了然后配置他的环境变量新建一个MAVEN_HOME,变量值复制自己的路径黏贴即可:将%MAVEN_HOME%\bin;添加到Path后面按住WIN+R组合键,输入CMD回车,在DOS窗口输入mvn-v测试安装结果,成功后如下图:2.配置maven本地仓库在C盘新建apache-mave…

    2022年6月18日
    83
  • 少儿编程mta证书_少儿编程项目计划书

    少儿编程项目计划书未来30年是人工智能的伟大时代,学编程会让孩子的未来充满更多可能性。此项目是针对小学生,主要是以培养学习兴趣,接受最基本的编程概念,并能够通过学到的知识完成一些小的课题,激发和培养学生的编程思维。在学习的过程中,主要通过实体的编程玩具,学会构建自己的作品,比如学习编程语言,机器人等课程。本项目提供多维度的少儿编程培训服务,包括编辑机器人研发、在线编程教育培训、线下培训等。一、线下…

    2022年4月8日
    40
  • 机械振动论文带有simulink分析的_matlab振动仿真实例

    机械振动论文带有simulink分析的_matlab振动仿真实例1、内容简介1、汽车传动系统的力学模型的讨论2、SIMULINK介绍3、(激励源分析并建立相应的SIMULINK模块)包括发动机动力源模型,行驶工况等4、分析扭振特性5、提出改进手段并比较改进前后系统扭振响应340-可以交流、咨询、答疑2、内容说明汽车动力传动系统是一个具有多自由度的、连续的、有阻尼系统。传动系统的振动主要有横向振动、扭转振动、纵向振动。并且汽车传动系统的扭转振动是一个非常重要的振动形式。当汽车制动、起步、换档时,这些非稳定工况下汽车传动系由于受到非周期的冲击性干扰力而产生的振动。当汽车正

    2022年10月15日
    0

发表回复

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

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